-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #198 from vrrao01/upgrader
Upgrader
- Loading branch information
Showing
5 changed files
with
124 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,65 @@ | ||
import 'package:badges/badges.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:onestop_dev/globals/my_colors.dart'; | ||
import 'package:onestop_dev/globals/my_fonts.dart'; | ||
|
||
class HomeTabTile extends StatelessWidget { | ||
const HomeTabTile( | ||
{Key? key, required this.label, required this.icon, this.routeId}) | ||
{Key? key, required this.label, required this.icon, this.routeId, this.newBadge = false}) | ||
: super(key: key); | ||
|
||
final String label; | ||
final IconData icon; | ||
final String? routeId; | ||
final bool newBadge; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Expanded( | ||
child: FittedBox( | ||
child: GestureDetector( | ||
onTap: () => Navigator.pushNamed(context, routeId ?? "/"), | ||
child: Container( | ||
//margin: EdgeInsets.all(4), | ||
height: 150, | ||
width: 150, | ||
decoration: BoxDecoration( | ||
borderRadius: BorderRadius.circular(50), color: lGrey), | ||
padding: const EdgeInsets.all(4.0), | ||
child: Column( | ||
// Replace with a Row for horizontal icon + text | ||
mainAxisAlignment: MainAxisAlignment.start, | ||
children: <Widget>[ | ||
const SizedBox( | ||
height: 8, | ||
), | ||
Expanded( | ||
child: Icon( | ||
icon, | ||
size: 40, | ||
color: lBlue, | ||
), | ||
), | ||
Expanded( | ||
child: Text(label, | ||
style: MyFonts.w500.size(23).setColor(lBlue), | ||
textAlign: TextAlign.center), | ||
Widget finalWidget = FittedBox( | ||
child: GestureDetector( | ||
onTap: () => Navigator.pushNamed(context, routeId ?? "/"), | ||
child: Container( | ||
//margin: EdgeInsets.all(4), | ||
height: 150, | ||
width: 150, | ||
decoration: BoxDecoration( | ||
borderRadius: BorderRadius.circular(50), color: lGrey), | ||
padding: const EdgeInsets.all(4.0), | ||
child: Column( | ||
// Replace with a Row for horizontal icon + text | ||
mainAxisAlignment: MainAxisAlignment.start, | ||
children: <Widget>[ | ||
const SizedBox( | ||
height: 8, | ||
), | ||
Expanded( | ||
child: Icon( | ||
icon, | ||
size: 40, | ||
color: lBlue, | ||
), | ||
], | ||
), | ||
), | ||
Expanded( | ||
child: Text(label, | ||
style: MyFonts.w500.size(23).setColor(lBlue), | ||
textAlign: TextAlign.center), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
if (newBadge) { | ||
finalWidget = Badge( | ||
shape: BadgeShape.square, | ||
borderRadius: BorderRadius.circular(8), | ||
badgeContent: Text('New', style: MyFonts.w600.setColor(Color.fromRGBO(62, 71, 88, 1)).size(10),), | ||
badgeColor: Color.fromRGBO(255, 201, 7, 1), | ||
child:finalWidget, | ||
); | ||
} | ||
return Expanded( | ||
child: finalWidget, | ||
); | ||
} | ||
} |
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,48 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:onestop_dev/globals/my_colors.dart'; | ||
import 'package:onestop_dev/globals/my_fonts.dart'; | ||
import 'package:upgrader/upgrader.dart'; | ||
|
||
|
||
class OneStopUpgraderMessages extends UpgraderMessages { | ||
@override | ||
String get title => 'OneStop Update Available'; | ||
@override | ||
String get body => 'OneStop v{{currentAppStoreVersion}} is now available. You are on a previous version - v{{currentInstalledVersion}}'; | ||
} | ||
|
||
|
||
class OneStopUpgrader extends StatelessWidget { | ||
final Widget child; | ||
const OneStopUpgrader({Key? key, required this.child}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Theme( | ||
data: Theme.of(context).copyWith( | ||
dialogTheme: DialogTheme( | ||
backgroundColor: kBackground, | ||
titleTextStyle: MyFonts.w600.setColor(lBlue).size(20), | ||
contentTextStyle: MyFonts.w400.setColor(lBlue), | ||
), | ||
textButtonTheme: TextButtonThemeData( | ||
style: TextButton.styleFrom( | ||
foregroundColor: lBlue2, | ||
textStyle: MyFonts.w600 | ||
) | ||
) | ||
), | ||
child: UpgradeAlert( | ||
upgrader: Upgrader( | ||
countryCode: 'IN', | ||
durationUntilAlertAgain: const Duration(hours: 1), | ||
debugDisplayAlways: true, | ||
showIgnore: false, | ||
messages: OneStopUpgraderMessages(), | ||
), | ||
child: child | ||
), | ||
); | ||
} | ||
} | ||
|
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