Skip to content

Commit eba5325

Browse files
committed
fix(ui): desktop shopinbit dialog flow nested navigation
1 parent d512c58 commit eba5325

11 files changed

Lines changed: 395 additions & 266 deletions

File tree

lib/pages/shopinbit/shopinbit_step_1.dart

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,9 @@ class _ShopInBitStep1State extends State<ShopInBitStep1> {
3232

3333
void _continue() {
3434
widget.model.displayName = _nameController.text.trim();
35-
if (Util.isDesktop) {
36-
Navigator.of(context, rootNavigator: true).pop();
37-
showDialog<void>(
38-
context: context,
39-
barrierDismissible: false,
40-
builder: (_) => ShopInBitStep2(model: widget.model),
41-
);
42-
} else {
43-
Navigator.of(
44-
context,
45-
).pushNamed(ShopInBitStep2.routeName, arguments: widget.model);
46-
}
35+
Navigator.of(
36+
context,
37+
).pushNamed(ShopInBitStep2.routeName, arguments: widget.model);
4738
}
4839

4940
@override

lib/pages/shopinbit/shopinbit_step_2.dart

Lines changed: 30 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import '../../widgets/desktop/primary_button.dart';
1515
import '../../widgets/dialogs/s_dialog.dart';
1616
import '../../widgets/rounded_container.dart';
1717
import '../exchange_view/sub_widgets/step_row.dart';
18-
import 'shopinbit_step_1.dart';
1918
import 'shopinbit_step_3.dart';
2019
import 'shopinbit_step_4.dart';
2120

@@ -33,46 +32,19 @@ class ShopInBitStep2 extends StatefulWidget {
3332
class _ShopInBitStep2State extends State<ShopInBitStep2> {
3433
ShopInBitCategory? _selected;
3534

36-
void _popBack() {
37-
if (Util.isDesktop) {
38-
Navigator.of(context, rootNavigator: true).pop();
39-
showDialog<void>(
40-
context: context,
41-
barrierDismissible: false,
42-
builder: (_) => ShopInBitStep1(model: widget.model),
43-
);
44-
} else {
45-
Navigator.of(context).pop();
46-
}
47-
}
48-
4935
void _continue() {
5036
widget.model.category = _selected;
5137
final skipGuidelines = ShopInBitService.instance.loadGuidelinesAccepted();
5238

53-
if (Util.isDesktop) {
54-
Navigator.of(context, rootNavigator: true).pop();
55-
if (skipGuidelines) {
56-
widget.model.guidelinesAccepted = true;
57-
Navigator.of(
58-
context,
59-
).pushNamed(ShopInBitStep4.routeName, arguments: widget.model);
60-
} else {
61-
Navigator.of(
62-
context,
63-
).pushNamed(ShopInBitStep3.routeName, arguments: widget.model);
64-
}
39+
if (skipGuidelines) {
40+
widget.model.guidelinesAccepted = true;
41+
Navigator.of(
42+
context,
43+
).pushNamed(ShopInBitStep4.routeName, arguments: widget.model);
6544
} else {
66-
if (skipGuidelines) {
67-
widget.model.guidelinesAccepted = true;
68-
Navigator.of(
69-
context,
70-
).pushNamed(ShopInBitStep4.routeName, arguments: widget.model);
71-
} else {
72-
Navigator.of(
73-
context,
74-
).pushNamed(ShopInBitStep3.routeName, arguments: widget.model);
75-
}
45+
Navigator.of(
46+
context,
47+
).pushNamed(ShopInBitStep3.routeName, arguments: widget.model);
7648
}
7749
}
7850

@@ -101,11 +73,7 @@ class _ShopInBitStep2State extends State<ShopInBitStep2> {
10173
children: [
10274
Row(
10375
children: [
104-
AppBarBackButton(
105-
isCompact: true,
106-
iconSize: 23,
107-
onPressed: _popBack,
108-
),
76+
const AppBarBackButton(isCompact: true, iconSize: 23),
10977
Text("ShopinBit", style: STextStyles.desktopH3(context)),
11078
],
11179
),
@@ -125,40 +93,29 @@ class _ShopInBitStep2State extends State<ShopInBitStep2> {
12593
child: ConditionalParent(
12694
condition: !isDesktop,
12795
builder: (content) => Background(
128-
child: PopScope(
129-
canPop: false,
130-
onPopInvokedWithResult: (bool didPop, dynamic result) {
131-
if (!didPop) {
132-
_popBack();
133-
}
134-
},
135-
child: Scaffold(
136-
backgroundColor: Theme.of(
137-
context,
138-
).extension<StackColors>()!.background,
139-
appBar: AppBar(
140-
leading: AppBarBackButton(onPressed: _popBack),
141-
title: Text(
142-
"ShopinBit",
143-
style: STextStyles.navBarTitle(context),
144-
),
145-
),
146-
body: SafeArea(
147-
child: LayoutBuilder(
148-
builder: (context, constraints) {
149-
return Padding(
150-
padding: const EdgeInsets.all(16),
151-
child: SingleChildScrollView(
152-
child: ConstrainedBox(
153-
constraints: BoxConstraints(
154-
minHeight: constraints.maxHeight - 32,
155-
),
156-
child: IntrinsicHeight(child: content),
96+
child: Scaffold(
97+
backgroundColor: Theme.of(
98+
context,
99+
).extension<StackColors>()!.background,
100+
appBar: AppBar(
101+
leading: const AppBarBackButton(),
102+
title: Text("ShopinBit", style: STextStyles.navBarTitle(context)),
103+
),
104+
body: SafeArea(
105+
child: LayoutBuilder(
106+
builder: (context, constraints) {
107+
return Padding(
108+
padding: const EdgeInsets.all(16),
109+
child: SingleChildScrollView(
110+
child: ConstrainedBox(
111+
constraints: BoxConstraints(
112+
minHeight: constraints.maxHeight - 32,
157113
),
114+
child: IntrinsicHeight(child: content),
158115
),
159-
);
160-
},
161-
),
116+
),
117+
);
118+
},
162119
),
163120
),
164121
),

lib/pages/shopinbit/shopinbit_step_3.dart

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import '../../widgets/desktop/desktop_dialog_close_button.dart';
1212
import '../../widgets/desktop/primary_button.dart';
1313
import '../../widgets/rounded_white_container.dart';
1414
import '../exchange_view/sub_widgets/step_row.dart';
15-
import 'shopinbit_step_2.dart';
1615
import 'shopinbit_step_4.dart';
1716

1817
class ShopInBitStep3 extends StatefulWidget {
@@ -74,35 +73,14 @@ class _ShopInBitStep3State extends State<ShopInBitStep3> {
7473
}
7574
}
7675

77-
void _popBack() {
78-
if (Util.isDesktop) {
79-
Navigator.of(context, rootNavigator: true).pop();
80-
showDialog<void>(
81-
context: context,
82-
barrierDismissible: false,
83-
builder: (_) => ShopInBitStep2(model: widget.model),
84-
);
85-
} else {
86-
Navigator.of(context).pop();
87-
}
88-
}
89-
9076
void _continue() {
9177
widget.model.guidelinesAccepted = true;
9278
// Persist acceptance.
9379
ShopInBitService.instance.setGuidelinesAccepted(true);
94-
if (Util.isDesktop) {
95-
Navigator.of(context, rootNavigator: true).pop();
96-
showDialog<void>(
97-
context: context,
98-
barrierDismissible: false,
99-
builder: (_) => ShopInBitStep4(model: widget.model),
100-
);
101-
} else {
102-
Navigator.of(
103-
context,
104-
).pushNamed(ShopInBitStep4.routeName, arguments: widget.model);
105-
}
80+
81+
Navigator.of(
82+
context,
83+
).pushNamed(ShopInBitStep4.routeName, arguments: widget.model);
10684
}
10785

10886
@override
@@ -184,11 +162,7 @@ class _ShopInBitStep3State extends State<ShopInBitStep3> {
184162
children: [
185163
Row(
186164
children: [
187-
AppBarBackButton(
188-
isCompact: true,
189-
iconSize: 23,
190-
onPressed: _popBack,
191-
),
165+
const AppBarBackButton(isCompact: true, iconSize: 23),
192166
Text("ShopinBit", style: STextStyles.desktopH3(context)),
193167
],
194168
),
@@ -213,9 +187,7 @@ class _ShopInBitStep3State extends State<ShopInBitStep3> {
213187
child: Scaffold(
214188
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
215189
appBar: AppBar(
216-
leading: AppBarBackButton(
217-
onPressed: () => Navigator.of(context).pop(),
218-
),
190+
leading: const AppBarBackButton(),
219191
title: Text("ShopinBit", style: STextStyles.navBarTitle(context)),
220192
),
221193
body: SafeArea(

0 commit comments

Comments
 (0)