Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show release notes after update #178

Merged
merged 7 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 5 additions & 35 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ on:
description: "Version"
required: true
type: string
release-notes:
description: "Release notes"
required: true
type: string
run-integration-tests:
description: "Run integration tests"
required: true
Expand Down Expand Up @@ -60,25 +56,9 @@ jobs:
stage-backend: false
version: ${{ inputs.version }}

generate-release-notes:
name: Generate release notes
needs: [build-android, build-ios]
runs-on: ubuntu-latest
steps:
- name: Generate release notes
run: |
echo ${{ inputs.release-notes }} > whatsnew-en-US.md
perl -i -pe 's/\s{1}(-{1})/\n$1/g' whatsnew-en-US.md

- name: Upload merged_native_libs.zip to artifacts
uses: actions/upload-artifact@v3
with:
name: whatsnew-en-US
path: whatsnew-en-US.md

create-github-release:
name: Create Github release
needs: [generate-release-notes]
needs: [build-android, build-ios]
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down Expand Up @@ -112,21 +92,16 @@ jobs:
- name: Rename apk
run: mv app-prod-release.apk m3_lightmeter.apk

- name: Download release notes
uses: actions/download-artifact@v3
with:
name: whatsnew-en-US

- uses: ncipollo/[email protected]
with:
artifacts: "m3_lightmeter.apk"
skipIfReleaseExists: true
tag: "v${{ github.event.inputs.version }}"
bodyFile: "whatsnew-en-US.md"
bodyFile: "assets/release_notes/release_notes_en_${{ inputs.version }}.md"

create-google-play-release:
name: Create Google Play release
needs: [generate-release-notes]
needs: [build-android, build-ios]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -143,14 +118,9 @@ jobs:
unzip app-prod-release.aab
(cd base/lib && zip -r "$OLDPWD/merged_native_libs.zip" .)

- name: Download release notes
uses: actions/download-artifact@v3
with:
name: whatsnew-en-US

- name: Move release notes to a folder
run: |
mv whatsnew-en-US.md whatsnew-en-US
mv assets/release_notes/release_notes_en_${{ inputs.version }}.md whatsnew-en-US
mkdir whatsnew
mv whatsnew-en-US whatsnew

Expand All @@ -177,7 +147,7 @@ jobs:

upload-to-app-store:
name: Upload to App Store
needs: [generate-release-notes]
needs: [build-android, build-ios]
runs-on: macos-13
steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 4 additions & 0 deletions assets/release_notes/release_notes_en_0.19.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- [Pro] Added a timer for shooting long exposures without leaving the app, just tap the necessary shutter speed in the list.
- Long exposure values are no longer limited by 1" and are generated to match the list of aperture values.
- Refined the app's color palette & unified icons across the app.
- Added release notes dialog.
4 changes: 4 additions & 0 deletions assets/release_notes/release_notes_ru_0.19.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- [Pro] Добавлен таймер для удобства съёмки при длительных выдержках. Достаточно просто нажать на нужное значение в списке экспозиционных пар.
- Длинные выдержки больше не ограничены 1" и генерируются в соответствии со значениями диафрагмы.
- Переработана цветовая палитра приложения и унифицированы иконки.
- Добавлен список изменений.
5 changes: 5 additions & 0 deletions lib/data/shared_prefs_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class UserPreferencesService {
static const primaryColorKey = "primaryColor";
static const dynamicColorKey = "dynamicColor";

static const seenChangelogVersionKey = "seenChangelogVersion";

final SharedPreferences _sharedPreferences;

UserPreferencesService(this._sharedPreferences) {
Expand Down Expand Up @@ -157,4 +159,7 @@ class UserPreferencesService {

bool get dynamicColor => _sharedPreferences.getBool(dynamicColorKey) ?? false;
set dynamicColor(bool value) => _sharedPreferences.setBool(dynamicColorKey, value);

String get seenChangelogVersion => _sharedPreferences.getString(seenChangelogVersionKey) ?? '';
set seenChangelogVersion(String value) => _sharedPreferences.setString(seenChangelogVersionKey, value);
}
12 changes: 11 additions & 1 deletion lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
import 'package:flutter/material.dart';
import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/screens/shared/release_notes_dialog/widget_dialog_release_notes.dart';
import 'package:package_info_plus/package_info_plus.dart';

class VersionListTile extends StatelessWidget {
const VersionListTile({super.key});

@override
Widget build(BuildContext context) {
return ListTile(
leading: const Icon(Icons.info_outline),
title: Text(S.of(context).version),
trailing: FutureBuilder<PackageInfo>(
future: PackageInfo.fromPlatform(),
builder: (context, snapshot) => snapshot.data != null
? Text(S.of(context).versionNumber(snapshot.data!.version, snapshot.data!.buildNumber))
: const SizedBox.shrink(),
return FutureBuilder<PackageInfo>(
future: PackageInfo.fromPlatform(),
builder: (context, snapshot) => ListTile(
leading: const Icon(Icons.info_outline),
title: Text(S.of(context).version),
onTap: snapshot.data != null
? () => showDialog(
context: context,
builder: (_) => ReleaseNotesDialog(version: snapshot.data!.version),
)
: null,
trailing: Text(S.of(context).versionNumber(snapshot.data?.version ?? '', snapshot.data?.buildNumber ?? '')),
),
);
}
Expand Down
27 changes: 27 additions & 0 deletions lib/screens/shared/release_notes_dialog/bloc_release_notes.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'dart:async';

import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:lightmeter/data/shared_prefs_service.dart';
import 'package:lightmeter/screens/shared/release_notes_dialog/state_release_notes.dart';
import 'package:package_info_plus/package_info_plus.dart';

class ReleaseNotesBloc extends Cubit<ReleaseNotesState> {
final UserPreferencesService _userPreferencesService;

ReleaseNotesBloc(this._userPreferencesService) : super(const HiddenReleaseNotesDialogState()) {
_showDialogIfNeeded();
}

Future<void> _showDialogIfNeeded() async {
PackageInfo.fromPlatform().then((value) {
emit(ShowReleaseNotesDialogState(value.version));
if (value.version != _userPreferencesService.seenChangelogVersion) {
emit(ShowReleaseNotesDialogState(value.version));
}
});
}

void setChangelogVersion() {
_userPreferencesService.seenChangelogVersion = (state as ShowReleaseNotesDialogState).version;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:lightmeter/providers/services_provider.dart';
import 'package:lightmeter/screens/shared/release_notes_dialog/bloc_release_notes.dart';
import 'package:lightmeter/screens/shared/release_notes_dialog/state_release_notes.dart';
import 'package:lightmeter/screens/shared/release_notes_dialog/widget_dialog_release_notes.dart';

class ReleaseNotesFlow extends StatelessWidget {
final Widget child;

const ReleaseNotesFlow({required this.child, super.key});

@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => ReleaseNotesBloc(ServicesProvider.of(context).userPreferencesService),
child: BlocListener<ReleaseNotesBloc, ReleaseNotesState>(
listener: (context, state) {
if (state is ShowReleaseNotesDialogState) {
showDialog(
context: context,
builder: (_) => ReleaseNotesDialog(version: state.version),
).then((_) => context.read<ReleaseNotesBloc>().setChangelogVersion());
}
},
child: child,
),
);
}
}
16 changes: 16 additions & 0 deletions lib/screens/shared/release_notes_dialog/state_release_notes.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:flutter/material.dart';

@immutable
sealed class ReleaseNotesState {
const ReleaseNotesState();
}

class HiddenReleaseNotesDialogState extends ReleaseNotesState {
const HiddenReleaseNotesDialogState();
}

class ShowReleaseNotesDialogState extends ReleaseNotesState {
final String version;

const ShowReleaseNotesDialogState(this.version);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart' show rootBundle;
import 'package:lightmeter/data/models/supported_locale.dart';
import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/providers/user_preferences_provider.dart';
import 'package:lightmeter/res/dimens.dart';

class ReleaseNotesDialog extends StatelessWidget {
final String version;

const ReleaseNotesDialog({required this.version, super.key});

@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text(S.of(context).whatsnew),
content: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
S.of(context).changesInVersion(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 {
late final String localeName;

switch (UserPreferencesProvider.localeOf(context)) {
case SupportedLocale.ru:
localeName = SupportedLocale.ru.name;
default:
localeName = SupportedLocale.en.name;
}

try {
return rootBundle.loadString('assets/release_notes/release_notes_${localeName}_$version.md');
} catch (e) {
return '';
}
}
}
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ flutter:
uses-material-design: true
assets:
- assets/camera_stub_image.jpg
- assets/release_notes/

flutter_intl:
enabled: true
Loading