Skip to content

Commit ceaae3d

Browse files
authored
Add OrdinalSortKey to Shrine shopping cart (#295)
1 parent 5d007ae commit ceaae3d

File tree

2 files changed

+60
-46
lines changed

2 files changed

+60
-46
lines changed

gallery/gallery/lib/studies/shrine/home.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import 'package:gallery/studies/shrine/model/app_state_model.dart';
1111
import 'package:gallery/studies/shrine/supplemental/asymmetric_view.dart';
1212
import 'package:scoped_model/scoped_model.dart';
1313

14+
const _ordinalSortKeyName = 'home';
15+
1416
class ProductPage extends StatelessWidget {
1517
const ProductPage();
1618

@@ -52,14 +54,14 @@ class HomePage extends StatelessWidget {
5254
Semantics(
5355
container: true,
5456
child: backdrop,
55-
sortKey: OrdinalSortKey(1),
57+
sortKey: OrdinalSortKey(1, name: _ordinalSortKeyName),
5658
),
5759
ExcludeSemantics(child: scrim),
5860
Align(
5961
child: Semantics(
6062
container: true,
6163
child: expandingBottomSheet,
62-
sortKey: OrdinalSortKey(0),
64+
sortKey: OrdinalSortKey(0, name: _ordinalSortKeyName),
6365
),
6466
alignment: isDesktop
6567
? AlignmentDirectional.topEnd

gallery/gallery/lib/studies/shrine/shopping_cart.dart

Lines changed: 56 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import 'package:gallery/studies/shrine/theme.dart';
1515
import 'package:gallery/l10n/gallery_localizations.dart';
1616

1717
const _startColumnWidth = 60.0;
18+
const _ordinalSortKeyName = 'shopping_cart';
1819

1920
class ShoppingCartPage extends StatefulWidget {
2021
@override
@@ -39,7 +40,6 @@ class _ShoppingCartPageState extends State<ShoppingCartPage> {
3940
@override
4041
Widget build(BuildContext context) {
4142
final ThemeData localTheme = Theme.of(context);
42-
4343
return Scaffold(
4444
backgroundColor: shrinePink50,
4545
body: SafeArea(
@@ -50,63 +50,75 @@ class _ShoppingCartPageState extends State<ShoppingCartPage> {
5050
children: [
5151
ListView(
5252
children: [
53-
Row(
54-
children: [
55-
SizedBox(
56-
width: _startColumnWidth,
57-
child: IconButton(
58-
icon: const Icon(Icons.keyboard_arrow_down),
59-
onPressed: () =>
60-
ExpandingBottomSheet.of(context).close(),
61-
tooltip: GalleryLocalizations.of(context)
62-
.shrineTooltipCloseCart,
53+
Semantics(
54+
sortKey: OrdinalSortKey(0, name: _ordinalSortKeyName),
55+
child: Row(
56+
children: [
57+
SizedBox(
58+
width: _startColumnWidth,
59+
child: IconButton(
60+
icon: const Icon(Icons.keyboard_arrow_down),
61+
onPressed: () =>
62+
ExpandingBottomSheet.of(context).close(),
63+
tooltip: GalleryLocalizations.of(context)
64+
.shrineTooltipCloseCart,
65+
),
6366
),
64-
),
65-
Text(
66-
GalleryLocalizations.of(context)
67-
.shrineCartPageCaption,
68-
style: localTheme.textTheme.subhead
69-
.copyWith(fontWeight: FontWeight.w600),
70-
),
71-
const SizedBox(width: 16),
72-
Text(
73-
GalleryLocalizations.of(context)
74-
.shrineCartItemCount(
75-
model.totalCartQuantity,
67+
Text(
68+
GalleryLocalizations.of(context)
69+
.shrineCartPageCaption,
70+
style: localTheme.textTheme.subhead
71+
.copyWith(fontWeight: FontWeight.w600),
7672
),
77-
),
78-
],
73+
const SizedBox(width: 16),
74+
Text(
75+
GalleryLocalizations.of(context)
76+
.shrineCartItemCount(
77+
model.totalCartQuantity,
78+
),
79+
),
80+
],
81+
),
7982
),
8083
const SizedBox(height: 16),
81-
Column(
82-
children: _createShoppingCartRows(model),
84+
Semantics(
85+
sortKey: OrdinalSortKey(1, name: _ordinalSortKeyName),
86+
child: Column(
87+
children: _createShoppingCartRows(model),
88+
),
89+
),
90+
Semantics(
91+
sortKey: OrdinalSortKey(2, name: _ordinalSortKeyName),
92+
child: ShoppingCartSummary(model: model),
8393
),
84-
ShoppingCartSummary(model: model),
8594
const SizedBox(height: 100),
8695
],
8796
),
8897
PositionedDirectional(
8998
bottom: 16,
9099
start: 16,
91100
end: 16,
92-
child: RaisedButton(
93-
shape: const BeveledRectangleBorder(
94-
borderRadius: BorderRadius.all(Radius.circular(7)),
95-
),
96-
color: shrinePink100,
97-
splashColor: shrineBrown600,
98-
child: Padding(
99-
padding: EdgeInsets.symmetric(vertical: 12),
100-
child: Text(
101-
GalleryLocalizations.of(context)
102-
.shrineCartClearButtonCaption,
103-
style: TextStyle(letterSpacing: largeLetterSpacing),
101+
child: Semantics(
102+
sortKey: OrdinalSortKey(3, name: _ordinalSortKeyName),
103+
child: RaisedButton(
104+
shape: const BeveledRectangleBorder(
105+
borderRadius: BorderRadius.all(Radius.circular(7)),
106+
),
107+
color: shrinePink100,
108+
splashColor: shrineBrown600,
109+
child: Padding(
110+
padding: EdgeInsets.symmetric(vertical: 12),
111+
child: Text(
112+
GalleryLocalizations.of(context)
113+
.shrineCartClearButtonCaption,
114+
style: TextStyle(letterSpacing: largeLetterSpacing),
115+
),
104116
),
117+
onPressed: () {
118+
model.clearCart();
119+
ExpandingBottomSheet.of(context).close();
120+
},
105121
),
106-
onPressed: () {
107-
model.clearCart();
108-
ExpandingBottomSheet.of(context).close();
109-
},
110122
),
111123
),
112124
],

0 commit comments

Comments
 (0)