Skip to content

Commit 4ef3fb3

Browse files
committed
fix: record order by using named params
1 parent 44042b0 commit 4ef3fb3

1 file changed

Lines changed: 74 additions & 66 deletions

File tree

lib/pages/more_view/services_view.dart

Lines changed: 74 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -31,81 +31,89 @@ class ServicesView extends ConsumerStatefulWidget {
3131

3232
class _ServicesViewState extends ConsumerState<ServicesView> {
3333
Future<void> _showShopDialog() async {
34-
final result = await showDialog<(ShopInBitSetting?, bool)>(
35-
context: context,
36-
barrierDismissible: true,
37-
builder: (context) => StackDialogBase(
38-
child: Column(
39-
crossAxisAlignment: CrossAxisAlignment.start,
40-
children: [
41-
Text("ShopinBit", style: STextStyles.pageTitleH2(context)),
42-
const SizedBox(height: 8),
43-
RichText(
44-
text: TextSpan(
45-
style: STextStyles.smallMed14(context),
46-
children: [
47-
const TextSpan(
48-
text:
49-
"Please note the following before proceeding:"
50-
"\n\n\u2022 Minimum order amount: 1,000 EUR"
51-
"\n\u2022 Service fee: 10% of the order total"
52-
"\n\nBy continuing, you agree to the ShopinBit ",
53-
),
54-
TextSpan(
55-
text: "Privacy Policy",
56-
style: STextStyles.richLink(context).copyWith(fontSize: 16),
57-
recognizer: TapGestureRecognizer()
58-
..onTap = () async {
59-
const url =
60-
"https://api.shopinbit.com/static/policy/privacy.html";
61-
62-
await showRequestExternalLinkAndMaybeLaunch(
63-
context,
64-
uri: Uri.parse(url),
65-
);
66-
},
67-
),
68-
const TextSpan(text: "."),
69-
],
70-
),
71-
),
72-
const SizedBox(height: 20),
73-
Row(
34+
final result =
35+
await showDialog<({ShopInBitSetting? settings, bool continuePressed})>(
36+
context: context,
37+
barrierDismissible: true,
38+
builder: (context) => StackDialogBase(
39+
child: Column(
40+
crossAxisAlignment: CrossAxisAlignment.start,
7441
children: [
75-
Expanded(
76-
child: SecondaryButton(
77-
label: "Cancel",
78-
onPressed: Navigator.of(context).pop,
42+
Text("ShopinBit", style: STextStyles.pageTitleH2(context)),
43+
const SizedBox(height: 8),
44+
RichText(
45+
text: TextSpan(
46+
style: STextStyles.smallMed14(context),
47+
children: [
48+
const TextSpan(
49+
text:
50+
"Please note the following before proceeding:"
51+
"\n\n\u2022 Minimum order amount: 1,000 EUR"
52+
"\n\u2022 Service fee: 10% of the order total"
53+
"\n\nBy continuing, you agree to the ShopinBit ",
54+
),
55+
TextSpan(
56+
text: "Privacy Policy",
57+
style: STextStyles.richLink(
58+
context,
59+
).copyWith(fontSize: 16),
60+
recognizer: TapGestureRecognizer()
61+
..onTap = () async {
62+
const url =
63+
"https://api.shopinbit.com/static/policy/privacy.html";
64+
65+
await showRequestExternalLinkAndMaybeLaunch(
66+
context,
67+
uri: Uri.parse(url),
68+
);
69+
},
70+
),
71+
const TextSpan(text: "."),
72+
],
7973
),
8074
),
81-
const SizedBox(width: 8),
82-
Expanded(
83-
child: TextButton(
84-
style: Theme.of(context)
85-
.extension<StackColors>()!
86-
.getPrimaryEnabledButtonStyle(context),
87-
onPressed: () async {
88-
final settings = await ref
89-
.read(pSharedDrift)
90-
.shopInBitSettingsDao
91-
.getCurrentSettings();
75+
const SizedBox(height: 20),
76+
Row(
77+
children: [
78+
Expanded(
79+
child: SecondaryButton(
80+
label: "Cancel",
81+
onPressed: Navigator.of(context).pop,
82+
),
83+
),
84+
const SizedBox(width: 8),
85+
Expanded(
86+
child: TextButton(
87+
style: Theme.of(context)
88+
.extension<StackColors>()!
89+
.getPrimaryEnabledButtonStyle(context),
90+
onPressed: () async {
91+
final settings = await ref
92+
.read(pSharedDrift)
93+
.shopInBitSettingsDao
94+
.getCurrentSettings();
9295

93-
if (!context.mounted) return;
96+
if (!context.mounted) return;
9497

95-
Navigator.of(context).pop((true, settings));
96-
},
97-
child: Text("Continue", style: STextStyles.button(context)),
98-
),
98+
Navigator.of(
99+
context,
100+
).pop((settings: settings, continuePressed: true));
101+
},
102+
child: Text(
103+
"Continue",
104+
style: STextStyles.button(context),
105+
),
106+
),
107+
),
108+
],
99109
),
100110
],
101111
),
102-
],
103-
),
104-
),
105-
);
112+
),
113+
);
106114

107-
if (mounted && result != null && result.$2 == true) {
108-
final settings = result.$1;
115+
if (mounted && result != null && result.continuePressed == true) {
116+
final settings = result.settings;
109117
if (settings != null && settings.setupComplete) {
110118
// Returning user: straight to category selection.
111119
await Navigator.of(context).pushNamed(ShopInBitStep2.routeName);

0 commit comments

Comments
 (0)