implemented release notes dialog

This commit is contained in:
Vadim 2024-05-21 21:32:40 +02:00
parent 4c34842597
commit d091f810de
3 changed files with 65 additions and 1 deletions

View file

@ -119,5 +119,15 @@
"tooltipUseLightSensor": "Use lightsensor",
"tooltipUseCamera": "Use camera",
"tooltipOpenSettings": "Open settings",
"exposurePair": "Exposure pair"
"exposurePair": "Exposure pair",
"whatsnew": "What's new?",
"changesInVersion": "Changes in version {version}:",
"@changesInVersion": {
"placeholders": {
"version": {
"type": "String"
}
}
},
"close": "Close"
}

View file

@ -0,0 +1,52 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart' show rootBundle;
import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/providers/user_preferences_provider.dart';
import 'package:lightmeter/res/dimens.dart';
import 'package:package_info_plus/package_info_plus.dart';
class ReleaseNotesDialog extends StatelessWidget {
const ReleaseNotesDialog({super.key});
@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text(S.of(context).whatsnew),
content: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
FutureBuilder<PackageInfo>(
future: PackageInfo.fromPlatform(),
builder: (context, snapshot) => Text(
S.of(context).changesInVersion(snapshot.data?.version ?? ''),
style: Theme.of(context).textTheme.titleSmall,
),
),
const SizedBox(height: Dimens.grid8),
FutureBuilder<String>(
future: loadReleaseNotes(context),
builder: (context, snapshot) => Text(snapshot.data ?? ''),
),
],
),
),
actions: [
TextButton(
onPressed: Navigator.of(context).pop,
child: Text(S.of(context).close),
),
],
);
}
Future<String> loadReleaseNotes(BuildContext context) async {
String path(String locale) => 'assets/release_notes/release_notes_$locale.md';
try {
return rootBundle.loadString(path(UserPreferencesProvider.localeOf(context).name));
} catch (e) {
return rootBundle.loadString(path('en'));
}
}
}

View file

@ -65,6 +65,8 @@ flutter:
uses-material-design: true
assets:
- assets/camera_stub_image.jpg
- assets/release_notes/release_notes_en.md
- assets/release_notes/release_notes_ru.md
flutter_intl:
enabled: true