-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'smarak/development' into products_v5
# Conflicts: # gogrocy/lib/service_locator.dart # gogrocy/lib/ui/router.dart
- Loading branch information
Showing
8 changed files
with
237 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import 'package:flushbar/flushbar.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:gogrocy/core/services/navigation_service.dart'; | ||
import 'package:gogrocy/core/services/shared_prefs.dart'; | ||
import 'package:gogrocy/core/viewModels/base_model.dart'; | ||
import 'package:gogrocy/service_locator.dart'; | ||
import 'package:gogrocy/ui/shared/colors.dart'; | ||
import 'package:gogrocy/ui/shared/constants.dart' as constants; | ||
import 'package:gogrocy/ui/views/base_view.dart'; | ||
import 'package:gogrocy/ui/widgets/vertical_spaces.dart'; | ||
|
||
class CitySelectionView extends StatelessWidget { | ||
final _navigationService = locator<NavigationService>(); | ||
final _sharedPrefsService = locator<SharedPrefsService>(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return BaseView<CitySelectionModel>( | ||
builder: (context, model, child) => SafeArea( | ||
child: Scaffold( | ||
backgroundColor: Colors.white, | ||
body: ListView( | ||
children: <Widget>[ | ||
VerticalSpaces.small20, | ||
Center( | ||
child: Text('Select City', style: TextStyle(fontSize: 20.0 * constants.scaleRatio),), | ||
), | ||
RadioListTile( | ||
title: Text("Jeypore"), | ||
subtitle: Text("Odisha"), | ||
activeColor: PRIMARY_COLOR, | ||
onChanged: (value) { | ||
model.setSelectedCityTile(value); | ||
}, | ||
groupValue: model.selectedCityTile, | ||
value: 1, | ||
), | ||
RadioListTile( | ||
title: Text("Sunabeda"), | ||
subtitle: Text("Odisha"), | ||
activeColor: PRIMARY_COLOR, | ||
onChanged: (value) { | ||
model.setSelectedCityTile(value); | ||
}, | ||
groupValue: model.selectedCityTile, | ||
value: 2, | ||
), | ||
Padding( | ||
padding: EdgeInsets.symmetric(horizontal: 100.0 * constants.scaleRatio,vertical: 50.0 * constants.scaleRatio), | ||
child: RaisedButton( | ||
shape: RoundedRectangleBorder( | ||
borderRadius: BorderRadius.circular(10.0)), | ||
color: Colors.black, | ||
child: Text( | ||
'Done', | ||
style: TextStyle( | ||
color: Colors.white, | ||
fontFamily: 'Gilroy', | ||
fontWeight: FontWeight.bold), | ||
), | ||
onPressed: () async { | ||
if (model.selectedCityTile == 0) { | ||
Flushbar( | ||
messageText: Text( | ||
"Select a city", | ||
style: TextStyle( | ||
color: Colors.black, fontWeight: FontWeight.w500), | ||
), | ||
flushbarStyle: FlushbarStyle.FLOATING, | ||
duration: Duration(seconds: 2), | ||
icon: Icon( | ||
Icons.error_outline, | ||
color: Colors.red, | ||
), | ||
shouldIconPulse: false, | ||
barBlur: 0.9, | ||
margin: EdgeInsets.all(8.0), | ||
borderRadius: 8.0, | ||
backgroundColor: Colors.white, | ||
boxShadows: [ | ||
BoxShadow( | ||
color: Colors.grey, | ||
offset: Offset(0.0, 0.0), | ||
blurRadius: 5.0, | ||
) | ||
], | ||
).show(context); | ||
} else { | ||
String city = | ||
model.selectedCityTile == 1 ? "Jeypore" : "Sunabeda"; | ||
await _sharedPrefsService.setCity(city); | ||
_navigationService.navigateTo('home'); | ||
} | ||
}, | ||
), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} | ||
|
||
class CitySelectionModel extends BaseModel { | ||
int selectedCityTile = 0; | ||
|
||
setSelectedCityTile(int val) { | ||
selectedCityTile = val; | ||
notifyListeners(); | ||
} | ||
} |
Oops, something went wrong.