fix: show actionsheet instead of inkwell on iOS
This commit is contained in:
parent
75913280be
commit
06d25b9a0c
2 changed files with 186 additions and 94 deletions
|
@ -19,6 +19,7 @@
|
||||||
- Welcome text on Setup view is now centered
|
- Welcome text on Setup view is now centered
|
||||||
- Editing entries is now done by tapping the entry, instead of a dedicated button
|
- Editing entries is now done by tapping the entry, instead of a dedicated button
|
||||||
- return iOS (Cupertino) widgets only on iOS/macOS
|
- return iOS (Cupertino) widgets only on iOS/macOS
|
||||||
|
- Show action sheet in graph settings on iOS instead of InkWell
|
||||||
|
|
||||||
# 1.0.0-alpha+5
|
# 1.0.0-alpha+5
|
||||||
- Add tests
|
- Add tests
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
import 'package:settings_ui/settings_ui.dart';
|
import 'package:settings_ui/settings_ui.dart';
|
||||||
|
@ -47,7 +50,47 @@ class _GraphTypeSettingsViewState extends State<GraphTypeSettingsView> {
|
||||||
? AppLocalizations.of(context).barChart
|
? AppLocalizations.of(context).barChart
|
||||||
: AppLocalizations.of(context).lineChart,
|
: AppLocalizations.of(context).lineChart,
|
||||||
),
|
),
|
||||||
onPressed: (c) => showAdaptiveDialog<void>(
|
onPressed: (c) {
|
||||||
|
if (Platform.isIOS) {
|
||||||
|
// iOS does not use Material widgets => no inkwell support
|
||||||
|
showCupertinoModalPopup<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (ctx) => CupertinoActionSheet(
|
||||||
|
title: Text(AppLocalizations.of(context).selectType),
|
||||||
|
actions: [
|
||||||
|
CupertinoActionSheetAction(
|
||||||
|
onPressed: () async {
|
||||||
|
final s = await SharedPreferences.getInstance();
|
||||||
|
await s.setInt("yearlygraph", 1);
|
||||||
|
_yearly = 1;
|
||||||
|
if (!ctx.mounted) return;
|
||||||
|
Navigator.of(ctx).pop();
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
AppLocalizations.of(context).barChart,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
CupertinoActionSheetAction(
|
||||||
|
onPressed: () async {
|
||||||
|
final s = await SharedPreferences.getInstance();
|
||||||
|
await s.setInt("yearlygraph", 2);
|
||||||
|
_yearly = 2;
|
||||||
|
if (!ctx.mounted) return;
|
||||||
|
Navigator.of(ctx).pop();
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
AppLocalizations.of(context).lineChart,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
showAdaptiveDialog<void>(
|
||||||
context: c,
|
context: c,
|
||||||
builder: (ctx) => AlertDialog.adaptive(
|
builder: (ctx) => AlertDialog.adaptive(
|
||||||
title: Text(AppLocalizations.of(context).selectType),
|
title: Text(AppLocalizations.of(context).selectType),
|
||||||
|
@ -66,7 +109,8 @@ class _GraphTypeSettingsViewState extends State<GraphTypeSettingsView> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final s = await SharedPreferences.getInstance();
|
final s =
|
||||||
|
await SharedPreferences.getInstance();
|
||||||
await s.setInt("yearlygraph", 1);
|
await s.setInt("yearlygraph", 1);
|
||||||
_yearly = 1;
|
_yearly = 1;
|
||||||
if (!ctx.mounted) return;
|
if (!ctx.mounted) return;
|
||||||
|
@ -86,7 +130,8 @@ class _GraphTypeSettingsViewState extends State<GraphTypeSettingsView> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final s = await SharedPreferences.getInstance();
|
final s =
|
||||||
|
await SharedPreferences.getInstance();
|
||||||
await s.setInt("yearlygraph", 2);
|
await s.setInt("yearlygraph", 2);
|
||||||
_yearly = 2;
|
_yearly = 2;
|
||||||
if (!ctx.mounted) return;
|
if (!ctx.mounted) return;
|
||||||
|
@ -99,7 +144,9 @@ class _GraphTypeSettingsViewState extends State<GraphTypeSettingsView> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
SettingsTile.navigation(
|
SettingsTile.navigation(
|
||||||
title: Text(AppLocalizations.of(context).monthly),
|
title: Text(AppLocalizations.of(context).monthly),
|
||||||
|
@ -108,7 +155,47 @@ class _GraphTypeSettingsViewState extends State<GraphTypeSettingsView> {
|
||||||
? AppLocalizations.of(context).barChart
|
? AppLocalizations.of(context).barChart
|
||||||
: AppLocalizations.of(context).lineChart,
|
: AppLocalizations.of(context).lineChart,
|
||||||
),
|
),
|
||||||
onPressed: (c) => showAdaptiveDialog<void>(
|
onPressed: (c) {
|
||||||
|
if (Platform.isIOS) {
|
||||||
|
// iOS does not use Material widgets => no inkwell support
|
||||||
|
showCupertinoModalPopup<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (ctx) => CupertinoActionSheet(
|
||||||
|
title: Text(AppLocalizations.of(context).selectType),
|
||||||
|
actions: [
|
||||||
|
CupertinoActionSheetAction(
|
||||||
|
onPressed: () async {
|
||||||
|
final s = await SharedPreferences.getInstance();
|
||||||
|
await s.setInt("monthlygraph", 1);
|
||||||
|
_monthly = 1;
|
||||||
|
if (!ctx.mounted) return;
|
||||||
|
Navigator.of(ctx).pop();
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
AppLocalizations.of(context).barChart,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
CupertinoActionSheetAction(
|
||||||
|
onPressed: () async {
|
||||||
|
final s = await SharedPreferences.getInstance();
|
||||||
|
await s.setInt("monthlygraph", 2);
|
||||||
|
_monthly = 2;
|
||||||
|
if (!ctx.mounted) return;
|
||||||
|
Navigator.of(ctx).pop();
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
AppLocalizations.of(context).lineChart,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
showAdaptiveDialog<void>(
|
||||||
context: c,
|
context: c,
|
||||||
builder: (ctx) => AlertDialog.adaptive(
|
builder: (ctx) => AlertDialog.adaptive(
|
||||||
title: Text(AppLocalizations.of(context).selectType),
|
title: Text(AppLocalizations.of(context).selectType),
|
||||||
|
@ -127,7 +214,8 @@ class _GraphTypeSettingsViewState extends State<GraphTypeSettingsView> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final s = await SharedPreferences.getInstance();
|
final s =
|
||||||
|
await SharedPreferences.getInstance();
|
||||||
await s.setInt("monthlygraph", 1);
|
await s.setInt("monthlygraph", 1);
|
||||||
_monthly = 1;
|
_monthly = 1;
|
||||||
if (!ctx.mounted) return;
|
if (!ctx.mounted) return;
|
||||||
|
@ -137,7 +225,7 @@ class _GraphTypeSettingsViewState extends State<GraphTypeSettingsView> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: MediaQuery.of(ctx).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
|
@ -147,7 +235,8 @@ class _GraphTypeSettingsViewState extends State<GraphTypeSettingsView> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final s = await SharedPreferences.getInstance();
|
final s =
|
||||||
|
await SharedPreferences.getInstance();
|
||||||
await s.setInt("monthlygraph", 2);
|
await s.setInt("monthlygraph", 2);
|
||||||
_monthly = 2;
|
_monthly = 2;
|
||||||
if (!ctx.mounted) return;
|
if (!ctx.mounted) return;
|
||||||
|
@ -160,7 +249,9 @@ class _GraphTypeSettingsViewState extends State<GraphTypeSettingsView> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue