mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-12-24 15:10:40 +00:00
implemented release notes dialog
This commit is contained in:
parent
4c34842597
commit
d091f810de
3 changed files with 65 additions and 1 deletions
|
@ -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"
|
||||
}
|
|
@ -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'));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue