Skip to content

Commit

Permalink
Add badge for new
Browse files Browse the repository at this point in the history
  • Loading branch information
vrrao01 committed Jan 14, 2023
1 parent 21e6410 commit c668f3f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 32 deletions.
76 changes: 44 additions & 32 deletions lib/widgets/home/home_tab_tile.dart
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,
);
}
}
1 change: 1 addition & 0 deletions lib/widgets/home/service_links.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ List<HomeTabTile> serviceLinks = [
label: "GC Score Board",
icon: FluentIcons.trophy_20_regular,
routeId: Scoreboard.id,
newBadge: true,
),
];
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ dependencies:
path: ^1.8.0
infinite_scroll_pagination: ^3.2.0
upgrader: ^5.1.0
badges: ^2.0.3


dev_dependencies:
Expand Down

0 comments on commit c668f3f

Please sign in to comment.