mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2025-04-26 11:20:41 +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 {
|
class _AnimatedOverlay extends StatelessWidget {
|
||||||
|
|
|
@ -69,9 +69,14 @@ class MeteringScreen extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
void pushNamed(BuildContext context, String routeName, {Object? arguments}) {
|
void pushNamed(BuildContext context, String routeName, {Object? arguments}) {
|
||||||
context.read<MeteringBloc>().add(const ScreenOnTopOpenedEvent());
|
final bloc = context.read<MeteringBloc>();
|
||||||
Navigator.pushNamed(context, routeName, arguments: arguments).then((_) {
|
bloc.add(const ScreenOnTopOpenedEvent());
|
||||||
context.read<MeteringBloc>().add(const ScreenOnTopClosedEvent());
|
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:lightmeter/generated/l10n.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class WriteEmailListTile extends StatelessWidget {
|
class WriteEmailListTile extends StatefulWidget {
|
||||||
const WriteEmailListTile({super.key});
|
const WriteEmailListTile({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<WriteEmailListTile> createState() => _WriteEmailListTileState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _WriteEmailListTileState extends State<WriteEmailListTile> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
|
@ -20,24 +25,30 @@ class WriteEmailListTile extends StatelessWidget {
|
||||||
mailToUrl,
|
mailToUrl,
|
||||||
mode: LaunchMode.externalApplication,
|
mode: LaunchMode.externalApplication,
|
||||||
);
|
);
|
||||||
} else {
|
} else if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
_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();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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),
|
title: Text(S.of(context).language),
|
||||||
trailing: Text(UserPreferencesProvider.localeOf(context).localizedName),
|
trailing: Text(UserPreferencesProvider.localeOf(context).localizedName),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
final prefs = UserPreferencesProvider.of(context);
|
||||||
showDialog<SupportedLocale>(
|
showDialog<SupportedLocale>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (_) => DialogPicker<SupportedLocale>(
|
builder: (_) => DialogPicker<SupportedLocale>(
|
||||||
|
@ -21,11 +22,11 @@ class LanguageListTile extends StatelessWidget {
|
||||||
title: S.of(context).chooseLanguage,
|
title: S.of(context).chooseLanguage,
|
||||||
selectedValue: UserPreferencesProvider.localeOf(context),
|
selectedValue: UserPreferencesProvider.localeOf(context),
|
||||||
values: SupportedLocale.values,
|
values: SupportedLocale.values,
|
||||||
titleAdapter: (context, value) => value.localizedName,
|
titleAdapter: (_, value) => value.localizedName,
|
||||||
),
|
),
|
||||||
).then((value) {
|
).then((value) {
|
||||||
if (value != null) {
|
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),
|
title: Text(S.of(context).fractionalStops),
|
||||||
trailing: Text(_typeToString(context, UserPreferencesProvider.stopTypeOf(context))),
|
trailing: Text(_typeToString(context, UserPreferencesProvider.stopTypeOf(context))),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
final prefs = UserPreferencesProvider.of(context);
|
||||||
showDialog<StopType>(
|
showDialog<StopType>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (_) => DialogPicker<StopType>(
|
builder: (_) => DialogPicker<StopType>(
|
||||||
|
@ -25,7 +26,7 @@ class StopTypeListTile extends StatelessWidget {
|
||||||
),
|
),
|
||||||
).then((value) {
|
).then((value) {
|
||||||
if (value != null) {
|
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),
|
leading: const Icon(Icons.palette_outlined),
|
||||||
title: Text(S.of(context).primaryColor),
|
title: Text(S.of(context).primaryColor),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
final prefs = UserPreferencesProvider.of(context);
|
||||||
showDialog<Color>(
|
showDialog<Color>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (_) => const PrimaryColorDialogPicker(),
|
builder: (_) => const PrimaryColorDialogPicker(),
|
||||||
).then((value) {
|
).then((value) {
|
||||||
if (value != null) {
|
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),
|
title: Text(S.of(context).theme),
|
||||||
trailing: Text(_typeToString(context, UserPreferencesProvider.themeTypeOf(context))),
|
trailing: Text(_typeToString(context, UserPreferencesProvider.themeTypeOf(context))),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
final prefs = UserPreferencesProvider.of(context);
|
||||||
showDialog<ThemeType>(
|
showDialog<ThemeType>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (_) => DialogPicker<ThemeType>(
|
builder: (_) => DialogPicker<ThemeType>(
|
||||||
|
@ -25,7 +26,7 @@ class ThemeTypeListTile extends StatelessWidget {
|
||||||
),
|
),
|
||||||
).then((value) {
|
).then((value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
UserPreferencesProvider.of(context).setThemeType(value);
|
prefs.setThemeType(value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,10 +21,11 @@ class ReleaseNotesFlow extends StatelessWidget {
|
||||||
child: BlocListener<ReleaseNotesBloc, ReleaseNotesState>(
|
child: BlocListener<ReleaseNotesBloc, ReleaseNotesState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is ShowReleaseNotesDialogState) {
|
if (state is ShowReleaseNotesDialogState) {
|
||||||
|
final bloc = context.read<ReleaseNotesBloc>();
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (_) => ReleaseNotesDialog(version: state.version),
|
builder: (_) => ReleaseNotesDialog(version: state.version),
|
||||||
).then((_) => context.read<ReleaseNotesBloc>().setChangelogVersion());
|
).then((_) => bloc.setChangelogVersion());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: child,
|
child: child,
|
||||||
|
|
Loading…
Reference in a new issue