11import 'package:cocktailpedia/util/cocktail.dart' ;
2+ import 'package:cocktailpedia/util/glass_type.dart' ;
23import 'package:cocktailpedia/widgets/custom_theme.dart' ;
34import 'package:flutter/material.dart' ;
45
@@ -15,17 +16,69 @@ class _UploadCocktailPropertiesStates extends State<UploadCocktailProperties> {
1516 final BorderRadius borderRadius = BorderRadius .circular (16 );
1617 final Padding divider = const Padding (padding: EdgeInsets .all (16 ));
1718
19+ GlassType glassType = const AnyGlassType ();
20+
1821 bool isShakerNeeded = false ;
1922 bool isCocktailSpoonNeeded = false ;
2023 bool isCocktailStrainerNeeded = false ;
2124
25+ ImageProvider get _imageReference => widget.cocktail.image[0 ].image;
26+
27+ void _displayGlassChooser () async {
28+ showDialog (
29+ context: context,
30+ builder: (BuildContext context) => CustomTheme (
31+ image: _imageReference,
32+ delay: const Duration (milliseconds: 100 ),
33+ builder: (ThemeData them) => AlertDialog (
34+ title: const Text ("Select a new glass type" ),
35+ icon: const Icon (Icons .local_bar),
36+ content: SingleChildScrollView (
37+ child: ListBody (
38+ children: GlassType .glassTypes
39+ .map ((e) => InkWell (
40+ onTap: () {
41+ setState (() {
42+ glassType = e;
43+ });
44+ Navigator .of (context).pop ();
45+ },
46+ child: Padding (
47+ padding: const EdgeInsets .all (8.0 ),
48+ child: Row (
49+ children: [
50+ SizedBox (
51+ width: 50 ,
52+ height: 50 ,
53+ child: Image (image: e.getImage ())),
54+ Text ("${e .name } glass" )
55+ ],
56+ ),
57+ ),
58+ ))
59+ .toList (),
60+ ),
61+ ),
62+ actions: < Widget > [
63+ TextButton (
64+ child: const Text ('Cancel' ),
65+ onPressed: () {
66+ Navigator .of (context).pop ();
67+ },
68+ ),
69+ ],
70+ ),
71+ ),
72+ );
73+ }
74+
2275 @override
2376 Widget build (BuildContext context) {
2477 final double imageWidth = MediaQuery .of (context).size.width - 64 ;
2578 final double imageHeight = 0.5 * imageWidth;
2679
2780 return CustomTheme (
28- image: widget.cocktail.image[ 0 ].image ,
81+ image: _imageReference ,
2982 delay: const Duration (milliseconds: 250 ),
3083 builder: (ThemeData theme) => Scaffold (
3184 appBar: AppBar (
@@ -105,20 +158,22 @@ class _UploadCocktailPropertiesStates extends State<UploadCocktailProperties> {
105158 Material (
106159 color: Colors .transparent,
107160 child: InkWell (
108- onTap: () {} ,
161+ onTap: _displayGlassChooser ,
109162 child: Padding (
110163 padding: const EdgeInsets .only (
111- right: 14 .0 ,
164+ right: 24 .0 ,
112165 left: 14.0 ,
113166 top: 8.0 ,
114167 bottom: 8.0 ,
115168 ),
116169 child: Row (
170+ mainAxisAlignment: MainAxisAlignment .spaceBetween,
117171 children: [
118172 Text (
119173 "Glass type" ,
120174 style: Theme .of (context).textTheme.titleMedium,
121175 ),
176+ Text (glassType.name)
122177 ],
123178 ),
124179 ),
0 commit comments