mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2025-01-18 11:20:40 +00:00
avoided async gaps
This commit is contained in:
parent
8a41ebcb29
commit
97f802273c
8 changed files with 53 additions and 26 deletions
|
@ -221,7 +221,13 @@ class AnimatedDialogState extends State<AnimatedDialog> with SingleTickerProvide
|
|||
});
|
||||
}
|
||||
|
||||
Future<void> close() => _animateReverse().then((_) => Navigator.of(context).pop());
|
||||
Future<void> close() {
|
||||
return _animateReverse().then((_) {
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class _AnimatedOverlay extends StatelessWidget {
|
||||
|
|
|
@ -69,9 +69,14 @@ class MeteringScreen extends StatelessWidget {
|
|||
}
|
||||
|
||||
void pushNamed(BuildContext context, String routeName, {Object? arguments}) {
|
||||
context.read<MeteringBloc>().add(const ScreenOnTopOpenedEvent());
|
||||
Navigator.pushNamed(context, routeName, arguments: arguments).then((_) {
|
||||
context.read<MeteringBloc>().add(const ScreenOnTopClosedEvent());
|
||||
final bloc = context.read<MeteringBloc>();
|
||||
bloc.add(const ScreenOnTopOpenedEvent());
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
routeName,
|
||||
arguments: arguments,
|
||||
).then((_) {
|
||||
bloc.add(const ScreenOnTopClosedEvent());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,14 @@ import 'package:lightmeter/constants.dart';
|
|||
import 'package:lightmeter/generated/l10n.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class WriteEmailListTile extends StatelessWidget {
|
||||
class WriteEmailListTile extends StatefulWidget {
|
||||
const WriteEmailListTile({super.key});
|
||||
|
||||
@override
|
||||
State<WriteEmailListTile> createState() => _WriteEmailListTileState();
|
||||
}
|
||||
|
||||
class _WriteEmailListTileState extends State<WriteEmailListTile> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
|
@ -20,24 +25,30 @@ class WriteEmailListTile extends StatelessWidget {
|
|||
mailToUrl,
|
||||
mode: LaunchMode.externalApplication,
|
||||
);
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(S.of(context).youDontHaveMailApp),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
action: SnackBarAction(
|
||||
label: S.of(context).copyEmail,
|
||||
onPressed: () {
|
||||
FlutterClipboard.copy(contactEmail).then((_) {
|
||||
ScaffoldMessenger.of(context).clearSnackBars();
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
} else if (mounted) {
|
||||
_showSnackBar();
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _showSnackBar() async {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(S.of(context).youDontHaveMailApp),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
action: SnackBarAction(
|
||||
label: S.of(context).copyEmail,
|
||||
onPressed: () {
|
||||
FlutterClipboard.copy(contactEmail).then((_) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).clearSnackBars();
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ class LanguageListTile extends StatelessWidget {
|
|||
title: Text(S.of(context).language),
|
||||
trailing: Text(UserPreferencesProvider.localeOf(context).localizedName),
|
||||
onTap: () {
|
||||
final prefs = UserPreferencesProvider.of(context);
|
||||
showDialog<SupportedLocale>(
|
||||
context: context,
|
||||
builder: (_) => DialogPicker<SupportedLocale>(
|
||||
|
@ -21,11 +22,11 @@ class LanguageListTile extends StatelessWidget {
|
|||
title: S.of(context).chooseLanguage,
|
||||
selectedValue: UserPreferencesProvider.localeOf(context),
|
||||
values: SupportedLocale.values,
|
||||
titleAdapter: (context, value) => value.localizedName,
|
||||
titleAdapter: (_, value) => value.localizedName,
|
||||
),
|
||||
).then((value) {
|
||||
if (value != null) {
|
||||
UserPreferencesProvider.of(context).setLocale(value);
|
||||
prefs.setLocale(value);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
@ -14,6 +14,7 @@ class StopTypeListTile extends StatelessWidget {
|
|||
title: Text(S.of(context).fractionalStops),
|
||||
trailing: Text(_typeToString(context, UserPreferencesProvider.stopTypeOf(context))),
|
||||
onTap: () {
|
||||
final prefs = UserPreferencesProvider.of(context);
|
||||
showDialog<StopType>(
|
||||
context: context,
|
||||
builder: (_) => DialogPicker<StopType>(
|
||||
|
@ -25,7 +26,7 @@ class StopTypeListTile extends StatelessWidget {
|
|||
),
|
||||
).then((value) {
|
||||
if (value != null) {
|
||||
UserPreferencesProvider.of(context).setStopType(value);
|
||||
prefs.setStopType(value);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
@ -22,12 +22,13 @@ class PrimaryColorListTile extends StatelessWidget {
|
|||
leading: const Icon(Icons.palette_outlined),
|
||||
title: Text(S.of(context).primaryColor),
|
||||
onTap: () {
|
||||
final prefs = UserPreferencesProvider.of(context);
|
||||
showDialog<Color>(
|
||||
context: context,
|
||||
builder: (_) => const PrimaryColorDialogPicker(),
|
||||
).then((value) {
|
||||
if (value != null) {
|
||||
UserPreferencesProvider.of(context).setPrimaryColor(value);
|
||||
prefs.setPrimaryColor(value);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
@ -14,6 +14,7 @@ class ThemeTypeListTile extends StatelessWidget {
|
|||
title: Text(S.of(context).theme),
|
||||
trailing: Text(_typeToString(context, UserPreferencesProvider.themeTypeOf(context))),
|
||||
onTap: () {
|
||||
final prefs = UserPreferencesProvider.of(context);
|
||||
showDialog<ThemeType>(
|
||||
context: context,
|
||||
builder: (_) => DialogPicker<ThemeType>(
|
||||
|
@ -25,7 +26,7 @@ class ThemeTypeListTile extends StatelessWidget {
|
|||
),
|
||||
).then((value) {
|
||||
if (value != null) {
|
||||
UserPreferencesProvider.of(context).setThemeType(value);
|
||||
prefs.setThemeType(value);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
@ -21,10 +21,11 @@ class ReleaseNotesFlow extends StatelessWidget {
|
|||
child: BlocListener<ReleaseNotesBloc, ReleaseNotesState>(
|
||||
listener: (context, state) {
|
||||
if (state is ShowReleaseNotesDialogState) {
|
||||
final bloc = context.read<ReleaseNotesBloc>();
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => ReleaseNotesDialog(version: state.version),
|
||||
).then((_) => context.read<ReleaseNotesBloc>().setChangelogVersion());
|
||||
).then((_) => bloc.setChangelogVersion());
|
||||
}
|
||||
},
|
||||
child: child,
|
||||
|
|
Loading…
Reference in a new issue