mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 22:09:06 +00:00
Add OrdinalSortKey to Shrine shopping cart (#295)
This commit is contained in:
@@ -11,6 +11,8 @@ import 'package:gallery/studies/shrine/model/app_state_model.dart';
|
|||||||
import 'package:gallery/studies/shrine/supplemental/asymmetric_view.dart';
|
import 'package:gallery/studies/shrine/supplemental/asymmetric_view.dart';
|
||||||
import 'package:scoped_model/scoped_model.dart';
|
import 'package:scoped_model/scoped_model.dart';
|
||||||
|
|
||||||
|
const _ordinalSortKeyName = 'home';
|
||||||
|
|
||||||
class ProductPage extends StatelessWidget {
|
class ProductPage extends StatelessWidget {
|
||||||
const ProductPage();
|
const ProductPage();
|
||||||
|
|
||||||
@@ -52,14 +54,14 @@ class HomePage extends StatelessWidget {
|
|||||||
Semantics(
|
Semantics(
|
||||||
container: true,
|
container: true,
|
||||||
child: backdrop,
|
child: backdrop,
|
||||||
sortKey: OrdinalSortKey(1),
|
sortKey: OrdinalSortKey(1, name: _ordinalSortKeyName),
|
||||||
),
|
),
|
||||||
ExcludeSemantics(child: scrim),
|
ExcludeSemantics(child: scrim),
|
||||||
Align(
|
Align(
|
||||||
child: Semantics(
|
child: Semantics(
|
||||||
container: true,
|
container: true,
|
||||||
child: expandingBottomSheet,
|
child: expandingBottomSheet,
|
||||||
sortKey: OrdinalSortKey(0),
|
sortKey: OrdinalSortKey(0, name: _ordinalSortKeyName),
|
||||||
),
|
),
|
||||||
alignment: isDesktop
|
alignment: isDesktop
|
||||||
? AlignmentDirectional.topEnd
|
? AlignmentDirectional.topEnd
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import 'package:gallery/studies/shrine/theme.dart';
|
|||||||
import 'package:gallery/l10n/gallery_localizations.dart';
|
import 'package:gallery/l10n/gallery_localizations.dart';
|
||||||
|
|
||||||
const _startColumnWidth = 60.0;
|
const _startColumnWidth = 60.0;
|
||||||
|
const _ordinalSortKeyName = 'shopping_cart';
|
||||||
|
|
||||||
class ShoppingCartPage extends StatefulWidget {
|
class ShoppingCartPage extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
@@ -39,7 +40,6 @@ class _ShoppingCartPageState extends State<ShoppingCartPage> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final ThemeData localTheme = Theme.of(context);
|
final ThemeData localTheme = Theme.of(context);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: shrinePink50,
|
backgroundColor: shrinePink50,
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
@@ -50,38 +50,47 @@ class _ShoppingCartPageState extends State<ShoppingCartPage> {
|
|||||||
children: [
|
children: [
|
||||||
ListView(
|
ListView(
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Semantics(
|
||||||
children: [
|
sortKey: OrdinalSortKey(0, name: _ordinalSortKeyName),
|
||||||
SizedBox(
|
child: Row(
|
||||||
width: _startColumnWidth,
|
children: [
|
||||||
child: IconButton(
|
SizedBox(
|
||||||
icon: const Icon(Icons.keyboard_arrow_down),
|
width: _startColumnWidth,
|
||||||
onPressed: () =>
|
child: IconButton(
|
||||||
ExpandingBottomSheet.of(context).close(),
|
icon: const Icon(Icons.keyboard_arrow_down),
|
||||||
tooltip: GalleryLocalizations.of(context)
|
onPressed: () =>
|
||||||
.shrineTooltipCloseCart,
|
ExpandingBottomSheet.of(context).close(),
|
||||||
|
tooltip: GalleryLocalizations.of(context)
|
||||||
|
.shrineTooltipCloseCart,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
Text(
|
||||||
Text(
|
GalleryLocalizations.of(context)
|
||||||
GalleryLocalizations.of(context)
|
.shrineCartPageCaption,
|
||||||
.shrineCartPageCaption,
|
style: localTheme.textTheme.subhead
|
||||||
style: localTheme.textTheme.subhead
|
.copyWith(fontWeight: FontWeight.w600),
|
||||||
.copyWith(fontWeight: FontWeight.w600),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 16),
|
|
||||||
Text(
|
|
||||||
GalleryLocalizations.of(context)
|
|
||||||
.shrineCartItemCount(
|
|
||||||
model.totalCartQuantity,
|
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(width: 16),
|
||||||
],
|
Text(
|
||||||
|
GalleryLocalizations.of(context)
|
||||||
|
.shrineCartItemCount(
|
||||||
|
model.totalCartQuantity,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Column(
|
Semantics(
|
||||||
children: _createShoppingCartRows(model),
|
sortKey: OrdinalSortKey(1, name: _ordinalSortKeyName),
|
||||||
|
child: Column(
|
||||||
|
children: _createShoppingCartRows(model),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Semantics(
|
||||||
|
sortKey: OrdinalSortKey(2, name: _ordinalSortKeyName),
|
||||||
|
child: ShoppingCartSummary(model: model),
|
||||||
),
|
),
|
||||||
ShoppingCartSummary(model: model),
|
|
||||||
const SizedBox(height: 100),
|
const SizedBox(height: 100),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -89,24 +98,27 @@ class _ShoppingCartPageState extends State<ShoppingCartPage> {
|
|||||||
bottom: 16,
|
bottom: 16,
|
||||||
start: 16,
|
start: 16,
|
||||||
end: 16,
|
end: 16,
|
||||||
child: RaisedButton(
|
child: Semantics(
|
||||||
shape: const BeveledRectangleBorder(
|
sortKey: OrdinalSortKey(3, name: _ordinalSortKeyName),
|
||||||
borderRadius: BorderRadius.all(Radius.circular(7)),
|
child: RaisedButton(
|
||||||
),
|
shape: const BeveledRectangleBorder(
|
||||||
color: shrinePink100,
|
borderRadius: BorderRadius.all(Radius.circular(7)),
|
||||||
splashColor: shrineBrown600,
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.symmetric(vertical: 12),
|
|
||||||
child: Text(
|
|
||||||
GalleryLocalizations.of(context)
|
|
||||||
.shrineCartClearButtonCaption,
|
|
||||||
style: TextStyle(letterSpacing: largeLetterSpacing),
|
|
||||||
),
|
),
|
||||||
|
color: shrinePink100,
|
||||||
|
splashColor: shrineBrown600,
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 12),
|
||||||
|
child: Text(
|
||||||
|
GalleryLocalizations.of(context)
|
||||||
|
.shrineCartClearButtonCaption,
|
||||||
|
style: TextStyle(letterSpacing: largeLetterSpacing),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
model.clearCart();
|
||||||
|
ExpandingBottomSheet.of(context).close();
|
||||||
|
},
|
||||||
),
|
),
|
||||||
onPressed: () {
|
|
||||||
model.clearCart();
|
|
||||||
ExpandingBottomSheet.of(context).close();
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user