From ead019e8e033cf7f3efce528016e57b844499401 Mon Sep 17 00:00:00 2001 From: Uttkarsh-raj Date: Wed, 7 Jun 2023 14:38:16 +0530 Subject: [PATCH 1/4] refactor and new star logic --- lib/data/export.dart | 2 +- lib/provider/favorite_provider.dart | 4 + lib/ui_components/alerts/alerts.dart | 31 +- lib/ui_components/buttons/buttons.dart | 32 +- lib/ui_components/cards/cards.dart | 42 ++- .../input_fields/input_fields.dart | 20 +- lib/ui_components/messages/messages.dart | 20 +- .../pricing_cards/pricing_cards.dart | 10 +- .../segmented_controls.dart | 0 .../segmented_control_screen.dart | 290 ++++++++---------- lib/ui_components/sliders/sliders.dart | 20 +- 11 files changed, 215 insertions(+), 256 deletions(-) rename lib/ui_components/segmented_controls/{ => all_segmented_controls}/segmented_controls.dart (100%) diff --git a/lib/data/export.dart b/lib/data/export.dart index 5861af1..6390682 100644 --- a/lib/data/export.dart +++ b/lib/data/export.dart @@ -50,7 +50,7 @@ export '../../ui_components/paginations/all_paginations/page3.dart'; export '../../ui_components/paginations/all_paginations/page4.dart'; export '../../ui_components/paginations/all_paginations/page5.dart'; export '../../ui_components/pricing_cards/All Pricing Cards/pricing_card/pricing_cards1.dart'; -export '../../ui_components/segmented_controls/segmented_controls.dart'; +export '../ui_components/segmented_controls/all_segmented_controls/segmented_controls.dart'; export '../../ui_components/sliders/all_sliders/dual_pointer_slider/slider4.dart'; export '../../ui_components/sliders/all_sliders/single_pointer_slider/slider1.dart'; export '../../ui_components/sliders/all_sliders/single_pointer_slider/slider2.dart'; diff --git a/lib/provider/favorite_provider.dart b/lib/provider/favorite_provider.dart index 0f5a1aa..81ca85e 100644 --- a/lib/provider/favorite_provider.dart +++ b/lib/provider/favorite_provider.dart @@ -527,4 +527,8 @@ class FavoritesProvider extends ChangeNotifier { db.saveData(favs); notifyListeners(); } + + bool starred(int index) { + return favs.contains(index); + } } diff --git a/lib/ui_components/alerts/alerts.dart b/lib/ui_components/alerts/alerts.dart index 4d9952a..2100eba 100644 --- a/lib/ui_components/alerts/alerts.dart +++ b/lib/ui_components/alerts/alerts.dart @@ -32,7 +32,6 @@ class _AlertScreenState extends State { const Alert4("AMessage", "ADescriptions"), ]; - List coluredAlertsColor = [null, null, null, null]; List coluredAlertsIndex = [14, 15, 16, 17]; final List simpleAlerts = [ @@ -42,7 +41,6 @@ class _AlertScreenState extends State { const Alert8("AMessage", "ADescriptions"), ]; - List simpleAlertsColor = [null, null, null, null]; List simpleAlertsIndex = [18, 19, 20, 21]; final List simpleAlertsDarkMode = [ @@ -52,7 +50,6 @@ class _AlertScreenState extends State { const Alert12("AMessage", "ADescriptions"), ]; - List simpleAlertsDarkModeColor = [null, null, null, null]; List simpleAlertsDarkModeIndex = [22, 23, 24, 25]; @override @@ -98,13 +95,14 @@ class _AlertScreenState extends State { onTap: () { favProviderModel .add(coluredAlertsIndex[index]); - setState(() { - coluredAlertsColor[index] = Colors.amber; - }); + setState(() {}); }, child: Icon( Icons.star_border_outlined, - color: coluredAlertsColor[index], + color: (favProviderModel + .starred(coluredAlertsIndex[index])) + ? Colors.amber + : null, ), ), ], @@ -154,13 +152,14 @@ class _AlertScreenState extends State { onTap: () { favProviderModel .add(simpleAlertsIndex[index]); - setState(() { - simpleAlertsColor[index] = Colors.amber; - }); + setState(() {}); }, child: Icon( Icons.star_border_outlined, - color: simpleAlertsColor[index], + color: (favProviderModel + .starred(simpleAlertsIndex[index])) + ? Colors.amber + : null, ), ), ], @@ -210,14 +209,14 @@ class _AlertScreenState extends State { onTap: () { favProviderModel .add(simpleAlertsIndex[index]); - setState(() { - simpleAlertsDarkModeColor[index] = - Colors.amber; - }); + setState(() {}); }, child: Icon( Icons.star_border_outlined, - color: simpleAlertsDarkModeColor[index], + color: (favProviderModel + .starred(simpleAlertsIndex[index])) + ? Colors.amber + : null, ), ), ], diff --git a/lib/ui_components/buttons/buttons.dart b/lib/ui_components/buttons/buttons.dart index cac3697..b54c680 100644 --- a/lib/ui_components/buttons/buttons.dart +++ b/lib/ui_components/buttons/buttons.dart @@ -31,7 +31,6 @@ class _ButtonScreenState extends State { const Button10("button"), ]; - List customOutlineButtonColor = [null, null, null]; List customOutlineButtonIndex = [1, 2, 3]; final List customElevatedButton = [ @@ -41,13 +40,11 @@ class _ButtonScreenState extends State { const Button7("button"), const Button9("button") ]; - List customElevatedButtonColor = [null, null, null, null, null]; List customElevatedButtonIndex = [4, 5, 6, 7, 8]; final List customTextButton = [ const Button6("button"), ]; - List customTextButtonColor = [null]; List customTextButtonIndex = [9]; @override @@ -98,14 +95,14 @@ class _ButtonScreenState extends State { onTap: () { favProviderModel .add(customElevatedButtonIndex[index]); - setState(() { - customElevatedButtonColor[index] = - Colors.amber; - }); + setState(() {}); }, child: Icon( Icons.star_border_outlined, - color: customElevatedButtonColor[index], + color: (favProviderModel.starred( + customElevatedButtonIndex[index])) + ? Colors.amber + : null, ), ), ], @@ -156,14 +153,14 @@ class _ButtonScreenState extends State { onTap: () { favProviderModel .add(customOutlineButtonIndex[index]); - setState(() { - customOutlineButtonColor[index] = - Colors.amber; - }); + setState(() {}); }, child: Icon( Icons.star_border_outlined, - color: customOutlineButtonColor[index], + color: (favProviderModel.starred( + customOutlineButtonIndex[index])) + ? Colors.amber + : null, ), ), ], @@ -214,13 +211,14 @@ class _ButtonScreenState extends State { onTap: () { favProviderModel .add(customTextButtonIndex[index]); - setState(() { - customTextButtonColor[index] = Colors.amber; - }); + setState(() {}); }, child: Icon( Icons.star_border_outlined, - color: customTextButtonColor[index], + color: (favProviderModel.starred( + customTextButtonIndex[index])) + ? Colors.amber + : null, ), ), ], diff --git a/lib/ui_components/cards/cards.dart b/lib/ui_components/cards/cards.dart index 213a755..e7924ba 100644 --- a/lib/ui_components/cards/cards.dart +++ b/lib/ui_components/cards/cards.dart @@ -24,28 +24,24 @@ class _CardScreenState extends State { FirstCard(), SecondCard(), ]; - List blogCardListColor = [null, null]; List blogCardListIndex = [26, 27]; final socialCardList = const [ ThirdCard(), FourthCard(), ]; - List socialCardListColor = [null, null]; List socialCardListIndex = [28, 29]; final blogCardDarKModeList = const [ FifthCard(), SixthCard(), ]; - List blogCardDarKModeListColor = [null, null]; List blogCardDarKModeListIndex = [30, 31]; final socialCardDarkModeList = const [ SeventhCard(), EightCard(), ]; - List socialCardDarkModeListColor = [null, null]; List socialCardDarkModeListIndex = [32, 33]; @override @@ -94,13 +90,14 @@ class _CardScreenState extends State { GestureDetector( onTap: () { favProviderModel.add(blogCardListIndex[index]); - setState(() { - blogCardListColor[index] = Colors.amber; - }); + setState(() {}); }, child: Icon( Icons.star_border_outlined, - color: blogCardListColor[index], + color: (favProviderModel + .starred(blogCardListIndex[index])) + ? Colors.amber + : null, ), ), ], @@ -151,13 +148,14 @@ class _CardScreenState extends State { onTap: () { favProviderModel .add(socialCardListIndex[index]); - setState(() { - socialCardListColor[index] = Colors.amber; - }); + setState(() {}); }, child: Icon( Icons.star_border_outlined, - color: socialCardListColor[index], + color: (favProviderModel + .starred(socialCardListIndex[index])) + ? Colors.amber + : null, ), ), ], @@ -208,14 +206,14 @@ class _CardScreenState extends State { onTap: () { favProviderModel .add(blogCardDarKModeListIndex[index]); - setState(() { - blogCardDarKModeListColor[index] = - Colors.amber; - }); + setState(() {}); }, child: Icon( Icons.star_border_outlined, - color: blogCardDarKModeListColor[index], + color: (favProviderModel.starred( + blogCardDarKModeListIndex[index])) + ? Colors.amber + : null, ), ), ], @@ -266,14 +264,14 @@ class _CardScreenState extends State { onTap: () { favProviderModel .add(socialCardDarkModeListIndex[index]); - setState(() { - socialCardDarkModeListColor[index] = - Colors.amber; - }); + setState(() {}); }, child: Icon( Icons.star_border_outlined, - color: socialCardDarkModeListColor[index], + color: (favProviderModel.starred( + socialCardDarkModeListIndex[index])) + ? Colors.amber + : null, ), ), ], diff --git a/lib/ui_components/input_fields/input_fields.dart b/lib/ui_components/input_fields/input_fields.dart index 3c289a9..12a8eff 100644 --- a/lib/ui_components/input_fields/input_fields.dart +++ b/lib/ui_components/input_fields/input_fields.dart @@ -39,7 +39,6 @@ class _InputFieldScreenState extends State { hinttext: "Write Description", ) ]; - List textareasColor = [null, null, null, null]; List textareasIndex = [37, 38, 39, 40]; final List inputfields = [ @@ -64,7 +63,6 @@ class _InputFieldScreenState extends State { hinttext: "Input Title", ), ]; - List inputfieldsColor = [null, null, null, null, null]; List inputfieldsIndex = [41, 42, 43, 44, 45]; @override @@ -112,13 +110,14 @@ class _InputFieldScreenState extends State { GestureDetector( onTap: () { favProviderModel.add(inputfieldsIndex[index]); - setState(() { - inputfieldsColor[index] = Colors.amber; - }); + setState(() {}); }, child: Icon( Icons.star_border_outlined, - color: inputfieldsColor[index], + color: (favProviderModel + .starred(inputfieldsIndex[index])) + ? Colors.amber + : null, ), ), ], @@ -167,13 +166,14 @@ class _InputFieldScreenState extends State { GestureDetector( onTap: () { favProviderModel.add(textareasIndex[index]); - setState(() { - textareasColor[index] = Colors.amber; - }); + setState(() {}); }, child: Icon( Icons.star_border_outlined, - color: textareasColor[index], + color: (favProviderModel + .starred(textareasIndex[index])) + ? Colors.amber + : null, ), ), ], diff --git a/lib/ui_components/messages/messages.dart b/lib/ui_components/messages/messages.dart index 4bc27e0..a9d4fa0 100644 --- a/lib/ui_components/messages/messages.dart +++ b/lib/ui_components/messages/messages.dart @@ -48,7 +48,6 @@ class _MessageScreenState extends State { ), ]; - List inboxMessagesColor = [null, null, null, null]; List inboxMessagesIndex = [52, 53, 54, 55]; final List bubbleChat = [ @@ -66,7 +65,6 @@ class _MessageScreenState extends State { ), ]; - List bubbleChatColor = [null, null, null, null]; List bubbleChatIndex = [56, 57, 58, 59]; @override @@ -113,13 +111,14 @@ class _MessageScreenState extends State { GestureDetector( onTap: () { favProviderModel.add(bubbleChatIndex[index]); - setState(() { - bubbleChatColor[index] = Colors.amber; - }); + setState(() {}); }, child: Icon( Icons.star_border_outlined, - color: bubbleChatColor[index], + color: (favProviderModel + .starred(bubbleChatIndex[index])) + ? Colors.amber + : null, ), ), ], @@ -167,13 +166,14 @@ class _MessageScreenState extends State { GestureDetector( onTap: () { favProviderModel.add(inboxMessagesIndex[index]); - setState(() { - inboxMessagesColor[index] = Colors.amber; - }); + setState(() {}); }, child: Icon( Icons.star_border_outlined, - color: inboxMessagesColor[index], + color: (favProviderModel + .starred(inboxMessagesIndex[index])) + ? Colors.amber + : null, ), ), ], diff --git a/lib/ui_components/pricing_cards/pricing_cards.dart b/lib/ui_components/pricing_cards/pricing_cards.dart index a0c8754..1ce8a8d 100644 --- a/lib/ui_components/pricing_cards/pricing_cards.dart +++ b/lib/ui_components/pricing_cards/pricing_cards.dart @@ -30,7 +30,6 @@ class _PricingCardScreenState extends State { buttonTextColor: Color(0xff0f172a), ), ]; - List pricingCardsColor = [null]; List pricingCardsIndex = [60]; @override @@ -77,13 +76,14 @@ class _PricingCardScreenState extends State { onTap: () { favProviderModel .add(pricingCardsIndex[index]); - setState(() { - pricingCardsColor[index] = Colors.amber; - }); + setState(() {}); }, child: Icon( Icons.star_border_outlined, - color: pricingCardsColor[index], + color: (favProviderModel + .starred(pricingCardsIndex[index])) + ? Colors.amber + : null, ), ), ], diff --git a/lib/ui_components/segmented_controls/segmented_controls.dart b/lib/ui_components/segmented_controls/all_segmented_controls/segmented_controls.dart similarity index 100% rename from lib/ui_components/segmented_controls/segmented_controls.dart rename to lib/ui_components/segmented_controls/all_segmented_controls/segmented_controls.dart diff --git a/lib/ui_components/segmented_controls/segmented_control_screen.dart b/lib/ui_components/segmented_controls/segmented_control_screen.dart index 511cfa9..07637b8 100644 --- a/lib/ui_components/segmented_controls/segmented_control_screen.dart +++ b/lib/ui_components/segmented_controls/segmented_control_screen.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../provider/favorite_provider.dart'; import '../../theme/theme.dart'; -import 'segmented_controls.dart'; +import 'all_segmented_controls/segmented_controls.dart'; class SegmentedControlScreen extends StatefulWidget { const SegmentedControlScreen({super.key}); @@ -25,184 +25,144 @@ class _SegmentedControlScreenState extends State { 1: buildSegment("Text", color), 2: buildSegment("Text", color), }; - List segmentedControlFavColor = [null, null, null, null]; - List segmentedControlFavIndex = [61, 62, 63, 64]; + List segmentedLightControl = [ + Center( + child: RectangularSelections( + values: const ['Text', 'Text', 'Text'], + onSelected: (index) {}, + ), + ), + Center( + child: RadioChips( + values: const ['Text', 'Text', 'Text'], + onSelected: (index) {}, + ), + ), + ]; + List segmentedControlDark = [ + Center( + child: SegmentedControlWidget( + choices: choices1, + ), + ), + Center( + child: SegmentedControlWidget( + choices: choices, + ), + ), + ]; + List segmentedControlLightFavIndex = [61, 62]; + List segmentedControlDarkFavIndex = [63, 64]; return Scaffold( body: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Consumer( - builder: (context, favProviderModel, child) => Column( - children: [ - Align( - alignment: Alignment.centerLeft, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Text("Segment Control Light Mode", - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - color: MyTheme.lightBluishColor)), - ), - ), - Center( - child: RectangularSelections( - values: const ['Text', 'Text', 'Text'], - onSelected: (index) {}, - ), - ), - Padding( - padding: const EdgeInsets.fromLTRB(0, 3, 20, 3), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Text('Add to favorite'), - const SizedBox( - width: 5, - ), - GestureDetector( - onTap: () { - favProviderModel.add(segmentedControlFavIndex[0]); - }, - child: Icon( - Icons.star_border_outlined, - color: segmentedControlFavColor[3], - ), - ), - ], - ), - ), - ], + Align( + alignment: Alignment.centerLeft, + child: Text( + "Segment Control Light Mode", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: MyTheme.lightBluishColor), ), ), - const SizedBox( - height: 20, - ), - Consumer( - builder: (context, favProviderModel, child) => Column( - children: [ - Center( - child: RadioChips( - values: const ['Text', 'Text', 'Text'], - onSelected: (index) {}, - ), - ), - Padding( - padding: const EdgeInsets.fromLTRB(0, 3, 20, 3), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Text('Add to favorite'), - const SizedBox( - width: 5, + const SizedBox(height: 10), + Wrap( + direction: Axis.horizontal, + children: List.generate( + segmentedLightControl.length, + (index) => Consumer( + builder: (context, favProviderModel, child) => Column( + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: segmentedLightControl[index], + ), + Padding( + padding: const EdgeInsets.fromLTRB(0, 3, 20, 3), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text('Add to favorite'), + const SizedBox( + width: 5, + ), + GestureDetector( + onTap: () { + favProviderModel + .add(segmentedControlLightFavIndex[index]); + setState(() {}); + }, + child: Icon( + Icons.star_border_outlined, + color: (favProviderModel.starred( + segmentedControlLightFavIndex[index])) + ? Colors.amber + : null, + ), + ), + ], ), - GestureDetector( - onTap: () { - favProviderModel.add(segmentedControlFavIndex[1]); - setState(() { - segmentedControlFavColor[2] = Colors.amber; - }); - }, - child: Icon( - Icons.star_border_outlined, - color: segmentedControlFavColor[2], - ), - ), - ], - ), + ), + ], ), - ], + ), ), ), - const SizedBox( - height: 20, - ), - Consumer( - builder: (context, favProviderModel, child) => Column( - children: [ - Align( - alignment: Alignment.centerLeft, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Text("Segment Control Dark Mode", - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - color: MyTheme.lightBluishColor)), - ), - ), - Center( - child: SegmentedControlWidget( - choices: choices1, - ), - ), - Padding( - padding: const EdgeInsets.fromLTRB(0, 3, 20, 3), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Text('Add to favorite'), - const SizedBox( - width: 5, - ), - GestureDetector( - onTap: () { - favProviderModel.add(segmentedControlFavIndex[2]); - setState(() { - segmentedControlFavColor[0] = Colors.amber; - }); - }, - child: Icon( - Icons.star_border_outlined, - color: segmentedControlFavColor[0], - ), - ), - ], - ), - ), - ], + Align( + alignment: Alignment.centerLeft, + child: Text( + "Segment Control Dark Mode", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: MyTheme.lightBluishColor), ), ), - const SizedBox( - height: 20, - ), - Consumer( - builder: (context, favProviderModel, child) => Column( - children: [ - Center( - child: SegmentedControlWidget( - choices: choices, - ), - ), - Padding( - padding: const EdgeInsets.fromLTRB(0, 3, 20, 3), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Text('Add to favorite'), - const SizedBox( - width: 5, - ), - GestureDetector( - onTap: () { - favProviderModel.add(segmentedControlFavIndex[3]); - setState(() { - segmentedControlFavColor[1] = Colors.amber; - }); - }, - child: Icon( - Icons.star_border_outlined, - color: segmentedControlFavColor[1], - ), + const SizedBox(height: 10), + Wrap( + direction: Axis.horizontal, + children: List.generate( + segmentedControlDark.length, + (index) => Consumer( + builder: (context, favProviderModel, child) => Column( + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: segmentedControlDark[index], + ), + Padding( + padding: const EdgeInsets.fromLTRB(0, 3, 20, 3), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text('Add to favorite'), + const SizedBox( + width: 5, + ), + GestureDetector( + onTap: () { + favProviderModel + .add(segmentedControlDarkFavIndex[index]); + setState(() {}); + }, + child: Icon( + Icons.star_border_outlined, + color: (favProviderModel.starred( + segmentedControlDarkFavIndex[index])) + ? Colors.amber + : null, + ), + ), + ], ), - ], - ), + ), + ], ), - ], + ), ), ), ], diff --git a/lib/ui_components/sliders/sliders.dart b/lib/ui_components/sliders/sliders.dart index fcd6638..bdaab61 100644 --- a/lib/ui_components/sliders/sliders.dart +++ b/lib/ui_components/sliders/sliders.dart @@ -23,7 +23,6 @@ class _SliderScreenState extends State { maxRange: 100, ), ]; - List dualPointSliderColor = [null]; List dualPointSliderIndex = [46]; final List singlePointSlider = [ @@ -43,7 +42,6 @@ class _SliderScreenState extends State { maxRange: 100, ), ]; - List singlePointSliderColor = [null, null, null, null, null]; List singlePointSliderIndex = [47, 48, 49, 50, 51]; @override @@ -86,13 +84,14 @@ class _SliderScreenState extends State { onTap: () { favProviderModel .add(singlePointSliderIndex[index]); - setState(() { - singlePointSliderColor[index] = Colors.amber; - }); + setState(() {}); }, child: Icon( Icons.star_border_outlined, - color: singlePointSliderColor[index], + color: (favProviderModel + .starred(singlePointSliderIndex[index])) + ? Colors.amber + : null, ), ), ], @@ -135,13 +134,14 @@ class _SliderScreenState extends State { onTap: () { favProviderModel .add(dualPointSliderIndex[index]); - setState(() { - dualPointSliderColor[index] = Colors.amber; - }); + setState(() {}); }, child: Icon( Icons.star_border_outlined, - color: dualPointSliderColor[index], + color: (favProviderModel + .starred(dualPointSliderIndex[index])) + ? Colors.amber + : null, ), ), ], From cb53aaec2f4eaa48dcfbbe5b72d16b7291376719 Mon Sep 17 00:00:00 2001 From: Uttkarsh-raj Date: Wed, 7 Jun 2023 14:46:19 +0530 Subject: [PATCH 2/4] added new stepper widgets to be able to favs --- lib/data/widget_category.dart | 2 +- .../bottom_navbars/bottom_navbars.dart | 582 +++++++++--------- lib/ui_components/radios/radios.dart | 64 +- lib/ui_components/steppers/steppers.dart | 74 ++- 4 files changed, 407 insertions(+), 315 deletions(-) diff --git a/lib/data/widget_category.dart b/lib/data/widget_category.dart index e0babbd..cd784d1 100644 --- a/lib/data/widget_category.dart +++ b/lib/data/widget_category.dart @@ -28,7 +28,7 @@ final List> widgetCategoryData = [ }, { 'categoryName': 'Bottom Navigation Bars', - 'categoryScreen': const BottomNavBarScreen(), + // 'categoryScreen': const BottomNavBarScreen(), }, { 'categoryName': 'Avatars', diff --git a/lib/ui_components/bottom_navbars/bottom_navbars.dart b/lib/ui_components/bottom_navbars/bottom_navbars.dart index 30b2888..4d726e9 100644 --- a/lib/ui_components/bottom_navbars/bottom_navbars.dart +++ b/lib/ui_components/bottom_navbars/bottom_navbars.dart @@ -1,297 +1,297 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_component_ui/provider/favorite_provider.dart'; -import 'package:provider/provider.dart'; -import '../../theme/theme.dart'; -import 'allBottomNavigationBars/animated_navbar/bottom_navbar4.dart'; -import 'allBottomNavigationBars/basic_navbars/bottom_navbar1.dart'; -import 'allBottomNavigationBars/basic_navbars/bottom_navbar2.dart'; -import 'allBottomNavigationBars/fab_navbars/bottom_navbar3.dart'; -import 'allBottomNavigationBars/fab_navbars/bottom_navbar5.dart'; -import 'allBottomNavigationBars/fab_navbars/bottom_navbar6.dart'; +// import 'package:flutter/material.dart'; +// import 'package:flutter_component_ui/provider/favorite_provider.dart'; +// import 'package:provider/provider.dart'; +// import '../../theme/theme.dart'; +// import 'allBottomNavigationBars/animated_navbar/bottom_navbar4.dart'; +// import 'allBottomNavigationBars/basic_navbars/bottom_navbar1.dart'; +// import 'allBottomNavigationBars/basic_navbars/bottom_navbar2.dart'; +// import 'allBottomNavigationBars/fab_navbars/bottom_navbar3.dart'; +// import 'allBottomNavigationBars/fab_navbars/bottom_navbar5.dart'; +// import 'allBottomNavigationBars/fab_navbars/bottom_navbar6.dart'; -class BottomNavBarScreen extends StatefulWidget { - const BottomNavBarScreen({super.key}); +// class BottomNavBarScreen extends StatefulWidget { +// const BottomNavBarScreen({super.key}); - @override - State createState() => BottomNavBarScreenState(); -} +// @override +// State createState() => BottomNavBarScreenState(); +// } -class BottomNavBarScreenState extends State { - final basicbottomNavbar = [ - const Bottom_Navbar1(), - const Bottom_Navbar2(), - ]; - List basicbottomNavbarColor = [null, null]; +// class BottomNavBarScreenState extends State { +// final basicbottomNavbar = [ +// const Bottom_Navbar1(), +// const Bottom_Navbar2(), +// ]; +// List basicbottomNavbarIndex = [null, null]; - final fabbottomNavbar = [ - const Bottom_Navbar3(), - const Bottom_Navbar5(), - const Bottom_Navbar6(), - ]; - List fabbottomNavbarColor = [null, null, null]; +// final fabbottomNavbar = [ +// const Bottom_Navbar3(), +// const Bottom_Navbar5(), +// const Bottom_Navbar6(), +// ]; +// List fabbottomNavbarIndex = [null, null, null]; - final animatedbottomNavbar = [ - const Bottom_Navbar4(), - ]; - List animatedbottomNavbarColor = [null]; +// final animatedbottomNavbar = [ +// const Bottom_Navbar4(), +// ]; +// List animatedbottomNavbarIndex = [null]; - @override - Widget build(BuildContext context) { - return Scaffold( - body: SafeArea( - child: SingleChildScrollView( - child: Column( - // mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Align( - alignment: Alignment.centerLeft, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Text("Basic Bottom Nav-Bars", - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - color: MyTheme.lightBluishColor)), - ), - ), - Wrap( - direction: Axis.horizontal, - children: List.generate( - basicbottomNavbar.length, - (index) => Consumer( - builder: (context, favProviderModel, child) => Column( - children: [ - Container( - padding: const EdgeInsets.symmetric( - horizontal: 12, - vertical: 8, - ), - constraints: const BoxConstraints( - minWidth: 400.0, // Set the minimum width constraint - maxWidth: 500.0, // Set the maximum width constraint - minHeight: - 50.0, // Set the minimum height constraint - maxHeight: - 100.0, // Set the maximum height constraint - ), - child: basicbottomNavbar[index], - ), - Padding( - padding: const EdgeInsets.fromLTRB(0, 3, 20, 3), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Text('Add to favorite'), - const SizedBox( - width: 5, - ), - GestureDetector( - onTap: () { - favProviderModel.add( - Container( - padding: const EdgeInsets.symmetric( - horizontal: 12, - vertical: 8, - ), - constraints: const BoxConstraints( - minWidth: - 400.0, // Set the minimum width constraint - maxWidth: - 500.0, // Set the maximum width constraint - minHeight: - 50.0, // Set the minimum height constraint - maxHeight: - 100.0, // Set the maximum height constraint - ), - child: basicbottomNavbar[index], - ), - ); - setState(() { - basicbottomNavbarColor[index] = - Colors.amber; - }); - }, - child: Icon( - Icons.star_border_outlined, - color: basicbottomNavbarColor[index], - ), - ), - ], - ), - ), - ], - ), - ), - ), - ), - Align( - alignment: Alignment.centerLeft, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Text("Animated Bottom Nav-Bars", - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - color: MyTheme.lightBluishColor)), - ), - ), - Wrap( - direction: Axis.horizontal, - children: List.generate( - animatedbottomNavbar.length, - (index) => Consumer( - builder: (context, favProviderModel, child) => Column( - children: [ - Container( - padding: const EdgeInsets.symmetric( - horizontal: 12, - vertical: 8, - ), - constraints: const BoxConstraints( - minWidth: 400.0, // Set the minimum width constraint - maxWidth: 500.0, // Set the maximum width constraint - minHeight: - 50.0, // Set the minimum height constraint - maxHeight: - 100.0, // Set the maximum height constraint - ), - child: animatedbottomNavbar[index], - ), - Padding( - padding: const EdgeInsets.fromLTRB(0, 3, 20, 3), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Text('Add to favorite'), - const SizedBox( - width: 5, - ), - GestureDetector( - onTap: () { - favProviderModel.add( - Container( - padding: const EdgeInsets.symmetric( - horizontal: 12, - vertical: 8, - ), - constraints: const BoxConstraints( - minWidth: - 400.0, // Set the minimum width constraint - maxWidth: - 500.0, // Set the maximum width constraint - minHeight: - 50.0, // Set the minimum height constraint - maxHeight: - 100.0, // Set the maximum height constraint - ), - child: animatedbottomNavbar[index], - ), - ); - setState(() { - animatedbottomNavbarColor[index] = - Colors.amber; - }); - }, - child: Icon( - Icons.star_border_outlined, - color: animatedbottomNavbarColor[index], - ), - ), - ], - ), - ), - ], - ), - ), - ), - ), - Align( - alignment: Alignment.centerLeft, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Text("FAB Bottom Nav-Bars", - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - color: MyTheme.lightBluishColor)), - ), - ), - Wrap( - direction: Axis.horizontal, - children: List.generate( - fabbottomNavbar.length, - (index) => Consumer( - builder: (context, favProviderModel, child) => Column( - children: [ - Container( - padding: const EdgeInsets.symmetric( - horizontal: 12, - vertical: 8, - ), - constraints: const BoxConstraints( - minWidth: 400.0, // Set the minimum width constraint - maxWidth: 500.0, // Set the maximum width constraint - minHeight: - 50.0, // Set the minimum height constraint - maxHeight: - 100.0, // Set the maximum height constraint - ), - child: fabbottomNavbar[index], - ), - Padding( - padding: const EdgeInsets.fromLTRB(0, 3, 20, 3), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Text('Add to favorite'), - const SizedBox( - width: 5, - ), - GestureDetector( - onTap: () { - favProviderModel.add( - Container( - padding: const EdgeInsets.symmetric( - horizontal: 12, - vertical: 8, - ), - constraints: const BoxConstraints( - minWidth: - 400.0, // Set the minimum width constraint - maxWidth: - 500.0, // Set the maximum width constraint - minHeight: - 50.0, // Set the minimum height constraint - maxHeight: - 100.0, // Set the maximum height constraint - ), - child: fabbottomNavbar[index], - ), - ); - setState(() { - fabbottomNavbarColor[index] = Colors.amber; - }); - }, - child: Icon( - Icons.star_border_outlined, - color: fabbottomNavbarColor[index], - ), - ), - ], - ), - ), - ], - ), - ), - ), - ), - ], - ), - ), - ), - ); - } -} +// @override +// Widget build(BuildContext context) { +// return Scaffold( +// body: SafeArea( +// child: SingleChildScrollView( +// child: Column( +// // mainAxisAlignment: MainAxisAlignment.spaceEvenly, +// children: [ +// Align( +// alignment: Alignment.centerLeft, +// child: Padding( +// padding: const EdgeInsets.all(8.0), +// child: Text("Basic Bottom Nav-Bars", +// style: TextStyle( +// fontSize: 20, +// fontWeight: FontWeight.bold, +// color: MyTheme.lightBluishColor)), +// ), +// ), +// Wrap( +// direction: Axis.horizontal, +// children: List.generate( +// basicbottomNavbar.length, +// (index) => Consumer( +// builder: (context, favProviderModel, child) => Column( +// children: [ +// Container( +// padding: const EdgeInsets.symmetric( +// horizontal: 12, +// vertical: 8, +// ), +// constraints: const BoxConstraints( +// minWidth: 400.0, // Set the minimum width constraint +// maxWidth: 500.0, // Set the maximum width constraint +// minHeight: +// 50.0, // Set the minimum height constraint +// maxHeight: +// 100.0, // Set the maximum height constraint +// ), +// child: basicbottomNavbar[index], +// ), +// Padding( +// padding: const EdgeInsets.fromLTRB(0, 3, 20, 3), +// child: Row( +// mainAxisAlignment: MainAxisAlignment.end, +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// const Text('Add to favorite'), +// const SizedBox( +// width: 5, +// ), +// GestureDetector( +// onTap: () { +// favProviderModel.add( +// Container( +// padding: const EdgeInsets.symmetric( +// horizontal: 12, +// vertical: 8, +// ), +// constraints: const BoxConstraints( +// minWidth: +// 400.0, // Set the minimum width constraint +// maxWidth: +// 500.0, // Set the maximum width constraint +// minHeight: +// 50.0, // Set the minimum height constraint +// maxHeight: +// 100.0, // Set the maximum height constraint +// ), +// child: basicbottomNavbar[index], +// ), +// ); +// setState(() { +// basicbottomNavbarColor[index] = +// Colors.amber; +// }); +// }, +// child: Icon( +// Icons.star_border_outlined, +// color: basicbottomNavbarColor[index], +// ), +// ), +// ], +// ), +// ), +// ], +// ), +// ), +// ), +// ), +// Align( +// alignment: Alignment.centerLeft, +// child: Padding( +// padding: const EdgeInsets.all(8.0), +// child: Text("Animated Bottom Nav-Bars", +// style: TextStyle( +// fontSize: 20, +// fontWeight: FontWeight.bold, +// color: MyTheme.lightBluishColor)), +// ), +// ), +// Wrap( +// direction: Axis.horizontal, +// children: List.generate( +// animatedbottomNavbar.length, +// (index) => Consumer( +// builder: (context, favProviderModel, child) => Column( +// children: [ +// Container( +// padding: const EdgeInsets.symmetric( +// horizontal: 12, +// vertical: 8, +// ), +// constraints: const BoxConstraints( +// minWidth: 400.0, // Set the minimum width constraint +// maxWidth: 500.0, // Set the maximum width constraint +// minHeight: +// 50.0, // Set the minimum height constraint +// maxHeight: +// 100.0, // Set the maximum height constraint +// ), +// child: animatedbottomNavbar[index], +// ), +// Padding( +// padding: const EdgeInsets.fromLTRB(0, 3, 20, 3), +// child: Row( +// mainAxisAlignment: MainAxisAlignment.end, +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// const Text('Add to favorite'), +// const SizedBox( +// width: 5, +// ), +// GestureDetector( +// onTap: () { +// favProviderModel.add( +// Container( +// padding: const EdgeInsets.symmetric( +// horizontal: 12, +// vertical: 8, +// ), +// constraints: const BoxConstraints( +// minWidth: +// 400.0, // Set the minimum width constraint +// maxWidth: +// 500.0, // Set the maximum width constraint +// minHeight: +// 50.0, // Set the minimum height constraint +// maxHeight: +// 100.0, // Set the maximum height constraint +// ), +// child: animatedbottomNavbar[index], +// ), +// ); +// setState(() { +// animatedbottomNavbarColor[index] = +// Colors.amber; +// }); +// }, +// child: Icon( +// Icons.star_border_outlined, +// color: animatedbottomNavbarColor[index], +// ), +// ), +// ], +// ), +// ), +// ], +// ), +// ), +// ), +// ), +// Align( +// alignment: Alignment.centerLeft, +// child: Padding( +// padding: const EdgeInsets.all(8.0), +// child: Text("FAB Bottom Nav-Bars", +// style: TextStyle( +// fontSize: 20, +// fontWeight: FontWeight.bold, +// color: MyTheme.lightBluishColor)), +// ), +// ), +// Wrap( +// direction: Axis.horizontal, +// children: List.generate( +// fabbottomNavbar.length, +// (index) => Consumer( +// builder: (context, favProviderModel, child) => Column( +// children: [ +// Container( +// padding: const EdgeInsets.symmetric( +// horizontal: 12, +// vertical: 8, +// ), +// constraints: const BoxConstraints( +// minWidth: 400.0, // Set the minimum width constraint +// maxWidth: 500.0, // Set the maximum width constraint +// minHeight: +// 50.0, // Set the minimum height constraint +// maxHeight: +// 100.0, // Set the maximum height constraint +// ), +// child: fabbottomNavbar[index], +// ), +// Padding( +// padding: const EdgeInsets.fromLTRB(0, 3, 20, 3), +// child: Row( +// mainAxisAlignment: MainAxisAlignment.end, +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// const Text('Add to favorite'), +// const SizedBox( +// width: 5, +// ), +// GestureDetector( +// onTap: () { +// favProviderModel.add( +// Container( +// padding: const EdgeInsets.symmetric( +// horizontal: 12, +// vertical: 8, +// ), +// constraints: const BoxConstraints( +// minWidth: +// 400.0, // Set the minimum width constraint +// maxWidth: +// 500.0, // Set the maximum width constraint +// minHeight: +// 50.0, // Set the minimum height constraint +// maxHeight: +// 100.0, // Set the maximum height constraint +// ), +// child: fabbottomNavbar[index], +// ), +// ); +// setState(() { +// fabbottomNavbarColor[index] = Colors.amber; +// }); +// }, +// child: Icon( +// Icons.star_border_outlined, +// color: fabbottomNavbarColor[index], +// ), +// ), +// ], +// ), +// ), +// ], +// ), +// ), +// ), +// ), +// ], +// ), +// ), +// ), +// ); +// } +// } diff --git a/lib/ui_components/radios/radios.dart b/lib/ui_components/radios/radios.dart index 87bb95f..cef141b 100644 --- a/lib/ui_components/radios/radios.dart +++ b/lib/ui_components/radios/radios.dart @@ -3,6 +3,9 @@ import 'package:flutter_component_ui/ui_components/radios/radio_widgets/basic_ra import 'package:flutter_component_ui/ui_components/radios/radio_widgets/radio_button_with_custom_color.dart'; import 'package:flutter_component_ui/ui_components/radios/radio_widgets/radio_button_with_horizontal_layout.dart'; import 'package:flutter_component_ui/ui_components/radios/radio_widgets/radio_button_with_text_and_styles.dart'; +import 'package:provider/provider.dart'; + +import '../../provider/favorite_provider.dart'; class RadioScreen extends StatefulWidget { const RadioScreen({super.key}); @@ -26,17 +29,56 @@ class _RadioScreenState extends State { return Scaffold( body: SingleChildScrollView( child: SafeArea( - child: Column(children: [ - Wrap( - direction: Axis.horizontal, - children: List.generate( - radios.length, - (index) => Padding( - padding: const EdgeInsets.all(8.0), - child: radios[index], - )), - ), - ]), + child: Column( + children: [ + Wrap( + direction: Axis.horizontal, + children: List.generate( + radiosIndex.length, + (index) => Consumer( + builder: (context, favProviderModel, child) => Column( + children: [ + Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), + width: double.infinity, + child: radios[index], + ), + Padding( + padding: const EdgeInsets.fromLTRB(0, 3, 20, 3), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text('Add to favorite'), + const SizedBox( + width: 5, + ), + GestureDetector( + onTap: () { + favProviderModel.add(radiosIndex[index]); + setState(() {}); + }, + child: Icon( + Icons.star_border_outlined, + color: (favProviderModel + .starred(radiosIndex[index])) + ? Colors.amber + : null, + ), + ), + ], + ), + ), + ], + ), + ), + ), + ), + ], + ), ), ), ); diff --git a/lib/ui_components/steppers/steppers.dart b/lib/ui_components/steppers/steppers.dart index 85bf43b..d3830b6 100644 --- a/lib/ui_components/steppers/steppers.dart +++ b/lib/ui_components/steppers/steppers.dart @@ -3,32 +3,82 @@ import 'package:flutter_component_ui/ui_components/steppers/steppers_widgets/bas import 'package:flutter_component_ui/ui_components/steppers/steppers_widgets/stepper_with_custom_color.dart'; import 'package:flutter_component_ui/ui_components/steppers/steppers_widgets/stepper_with_custom_icon.dart'; import 'package:flutter_component_ui/ui_components/steppers/steppers_widgets/stepper_with_validation.dart'; +import 'package:provider/provider.dart'; +import '../../provider/favorite_provider.dart'; -class StepperScreen extends StatelessWidget { +class StepperScreen extends StatefulWidget { StepperScreen({super.key}); + + @override + State createState() => _StepperScreenState(); +} + +class _StepperScreenState extends State { final List steppers = [ const BasicStepper(), const StepperwihCustomIcon(), const StepperwithValidation(), const StepperwithCustomColor(), ]; + + List stepperIndex = [70, 71, 72, 73]; + @override Widget build(BuildContext context) { return Scaffold( body: SingleChildScrollView( child: SafeArea( - child: Column(children: [ - Wrap( - direction: Axis.horizontal, - children: List.generate( - steppers.length, - (index) => Padding( - padding: const EdgeInsets.all(8.0), - child: steppers[index], - )), - ), - ]), + child: Column( + children: [ + Wrap( + direction: Axis.horizontal, + children: List.generate( + stepperIndex.length, + (index) => Consumer( + builder: (context, favProviderModel, child) => Column( + children: [ + Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), + width: double.infinity, + child: steppers[index], + ), + Padding( + padding: const EdgeInsets.fromLTRB(0, 3, 20, 3), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text('Add to favorite'), + const SizedBox( + width: 5, + ), + GestureDetector( + onTap: () { + favProviderModel.add(stepperIndex[index]); + setState(() {}); + }, + child: Icon( + Icons.star_border_outlined, + color: (favProviderModel + .starred(stepperIndex[index])) + ? Colors.amber + : null, + ), + ), + ], + ), + ), + ], + ), + ), + ), + ), + ], + ), ), ), ); From 0767614197aab33827ff6b467834c2531fce88b1 Mon Sep 17 00:00:00 2001 From: Uttkarsh-raj Date: Wed, 7 Jun 2023 15:03:14 +0530 Subject: [PATCH 3/4] added new bottom nav to fav and new function to the provider --- lib/data/export.dart | 11 + lib/data/widget_category.dart | 2 +- lib/provider/favorite_provider.dart | 138 ++++- .../bottom_navbars/bottom_navbars.dart | 532 ++++++++---------- 4 files changed, 390 insertions(+), 293 deletions(-) diff --git a/lib/data/export.dart b/lib/data/export.dart index 6390682..f5ddfd6 100644 --- a/lib/data/export.dart +++ b/lib/data/export.dart @@ -59,3 +59,14 @@ export '../../ui_components/radios/radio_widgets/basic_radio_button.dart'; export '../../ui_components/radios/radio_widgets/radio_button_with_custom_color.dart'; export '../../ui_components/radios/radio_widgets/radio_button_with_horizontal_layout.dart'; export '../../ui_components/radios/radio_widgets/radio_button_with_text_and_styles.dart'; +export '../ui_components/steppers/steppers_widgets/basic_stepper.dart'; +export '../ui_components/steppers/steppers_widgets/stepper_with_custom_color.dart'; +export '../ui_components/steppers/steppers_widgets/stepper_with_custom_icon.dart'; +export '../ui_components/steppers/steppers_widgets/stepper_with_validation.dart'; +export '../ui_components/alerts/all_alerts/dark_mode_alert/alert12.dart'; +export '../ui_components/bottom_navbars/allBottomNavigationBars/animated_navbar/bottom_navbar4.dart'; +export '../ui_components/bottom_navbars/allBottomNavigationBars/basic_navbars/bottom_navbar1.dart'; +export '../ui_components/bottom_navbars/allBottomNavigationBars/basic_navbars/bottom_navbar2.dart'; +export '../ui_components/bottom_navbars/allBottomNavigationBars/fab_navbars/bottom_navbar3.dart'; +export '../ui_components/bottom_navbars/allBottomNavigationBars/fab_navbars/bottom_navbar5.dart'; +export '../ui_components/bottom_navbars/allBottomNavigationBars/fab_navbars/bottom_navbar6.dart'; diff --git a/lib/data/widget_category.dart b/lib/data/widget_category.dart index cd784d1..e0babbd 100644 --- a/lib/data/widget_category.dart +++ b/lib/data/widget_category.dart @@ -28,7 +28,7 @@ final List> widgetCategoryData = [ }, { 'categoryName': 'Bottom Navigation Bars', - // 'categoryScreen': const BottomNavBarScreen(), + 'categoryScreen': const BottomNavBarScreen(), }, { 'categoryName': 'Avatars', diff --git a/lib/provider/favorite_provider.dart b/lib/provider/favorite_provider.dart index 81ca85e..84b317f 100644 --- a/lib/provider/favorite_provider.dart +++ b/lib/provider/favorite_provider.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_component_ui/data/hive_database.dart'; import '../data/export.dart'; -import '../ui_components/alerts/all_alerts/dark_mode_alert/alert12.dart'; import '../ui_components/messages/all_messages/bubble_message/message_2.dart'; import '../ui_components/messages/all_messages/bubble_message/message_3.dart'; import '../ui_components/messages/all_messages/bubble_message/message_4.dart'; @@ -507,6 +506,143 @@ class FavoritesProvider extends ChangeNotifier { hightlightColor: Color(0xFF00C2CB), ), ), + 70: Padding( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8), + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), + width: double.infinity, + child: const BasicStepper(), + ), + ), + 71: Padding( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8), + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), + width: double.infinity, + child: const StepperwihCustomIcon(), + ), + ), + 72: Padding( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8), + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), + width: double.infinity, + child: const StepperwithValidation(), + ), + ), + 73: Padding( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8), + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), + width: double.infinity, + child: const StepperwithCustomColor(), + ), + ), + 74: Padding( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8), + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), + constraints: const BoxConstraints( + minWidth: 400.0, + maxWidth: 500.0, + minHeight: 50.0, + maxHeight: 100.0, + ), + child: const Bottom_Navbar1(), + ), + ), + 75: Padding( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8), + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), + constraints: const BoxConstraints( + minWidth: 400.0, + maxWidth: 500.0, + minHeight: 50.0, + maxHeight: 100.0, + ), + child: const Bottom_Navbar2(), + ), + ), + 76: Padding( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8), + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), + constraints: const BoxConstraints( + minWidth: 400.0, + maxWidth: 500.0, + minHeight: 50.0, + maxHeight: 100.0, + ), + child: const Bottom_Navbar3(), + ), + ), + 77: Padding( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8), + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), + constraints: const BoxConstraints( + minWidth: 400.0, + maxWidth: 500.0, + minHeight: 50.0, + maxHeight: 100.0, + ), + child: const Bottom_Navbar5(), + ), + ), + 78: Padding( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8), + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), + constraints: const BoxConstraints( + minWidth: 400.0, + maxWidth: 500.0, + minHeight: 50.0, + maxHeight: 100.0, + ), + child: const Bottom_Navbar6(), + ), + ), + 79: Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), + constraints: const BoxConstraints( + minWidth: 400.0, + maxWidth: 500.0, + minHeight: 50.0, + maxHeight: 100.0, + ), + child: const Bottom_Navbar4(), + ), }; final db = HiveDatabase(); diff --git a/lib/ui_components/bottom_navbars/bottom_navbars.dart b/lib/ui_components/bottom_navbars/bottom_navbars.dart index 4d726e9..3bd08dd 100644 --- a/lib/ui_components/bottom_navbars/bottom_navbars.dart +++ b/lib/ui_components/bottom_navbars/bottom_navbars.dart @@ -1,297 +1,247 @@ -// import 'package:flutter/material.dart'; -// import 'package:flutter_component_ui/provider/favorite_provider.dart'; -// import 'package:provider/provider.dart'; -// import '../../theme/theme.dart'; -// import 'allBottomNavigationBars/animated_navbar/bottom_navbar4.dart'; -// import 'allBottomNavigationBars/basic_navbars/bottom_navbar1.dart'; -// import 'allBottomNavigationBars/basic_navbars/bottom_navbar2.dart'; -// import 'allBottomNavigationBars/fab_navbars/bottom_navbar3.dart'; -// import 'allBottomNavigationBars/fab_navbars/bottom_navbar5.dart'; -// import 'allBottomNavigationBars/fab_navbars/bottom_navbar6.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_component_ui/provider/favorite_provider.dart'; +import 'package:provider/provider.dart'; +import '../../theme/theme.dart'; +import 'allBottomNavigationBars/animated_navbar/bottom_navbar4.dart'; +import 'allBottomNavigationBars/basic_navbars/bottom_navbar1.dart'; +import 'allBottomNavigationBars/basic_navbars/bottom_navbar2.dart'; +import 'allBottomNavigationBars/fab_navbars/bottom_navbar3.dart'; +import 'allBottomNavigationBars/fab_navbars/bottom_navbar5.dart'; +import 'allBottomNavigationBars/fab_navbars/bottom_navbar6.dart'; -// class BottomNavBarScreen extends StatefulWidget { -// const BottomNavBarScreen({super.key}); +class BottomNavBarScreen extends StatefulWidget { + const BottomNavBarScreen({super.key}); -// @override -// State createState() => BottomNavBarScreenState(); -// } + @override + State createState() => BottomNavBarScreenState(); +} -// class BottomNavBarScreenState extends State { -// final basicbottomNavbar = [ -// const Bottom_Navbar1(), -// const Bottom_Navbar2(), -// ]; -// List basicbottomNavbarIndex = [null, null]; +class BottomNavBarScreenState extends State { + final basicbottomNavbar = [ + const Bottom_Navbar1(), + const Bottom_Navbar2(), + ]; + List basicbottomNavbarIndex = [74, 75]; -// final fabbottomNavbar = [ -// const Bottom_Navbar3(), -// const Bottom_Navbar5(), -// const Bottom_Navbar6(), -// ]; -// List fabbottomNavbarIndex = [null, null, null]; + final fabbottomNavbar = [ + const Bottom_Navbar3(), + const Bottom_Navbar5(), + const Bottom_Navbar6(), + ]; + List fabbottomNavbarIndex = [76, 77, 78]; -// final animatedbottomNavbar = [ -// const Bottom_Navbar4(), -// ]; -// List animatedbottomNavbarIndex = [null]; + final animatedbottomNavbar = [ + const Bottom_Navbar4(), + ]; + List animatedbottomNavbarIndex = [79]; -// @override -// Widget build(BuildContext context) { -// return Scaffold( -// body: SafeArea( -// child: SingleChildScrollView( -// child: Column( -// // mainAxisAlignment: MainAxisAlignment.spaceEvenly, -// children: [ -// Align( -// alignment: Alignment.centerLeft, -// child: Padding( -// padding: const EdgeInsets.all(8.0), -// child: Text("Basic Bottom Nav-Bars", -// style: TextStyle( -// fontSize: 20, -// fontWeight: FontWeight.bold, -// color: MyTheme.lightBluishColor)), -// ), -// ), -// Wrap( -// direction: Axis.horizontal, -// children: List.generate( -// basicbottomNavbar.length, -// (index) => Consumer( -// builder: (context, favProviderModel, child) => Column( -// children: [ -// Container( -// padding: const EdgeInsets.symmetric( -// horizontal: 12, -// vertical: 8, -// ), -// constraints: const BoxConstraints( -// minWidth: 400.0, // Set the minimum width constraint -// maxWidth: 500.0, // Set the maximum width constraint -// minHeight: -// 50.0, // Set the minimum height constraint -// maxHeight: -// 100.0, // Set the maximum height constraint -// ), -// child: basicbottomNavbar[index], -// ), -// Padding( -// padding: const EdgeInsets.fromLTRB(0, 3, 20, 3), -// child: Row( -// mainAxisAlignment: MainAxisAlignment.end, -// crossAxisAlignment: CrossAxisAlignment.start, -// children: [ -// const Text('Add to favorite'), -// const SizedBox( -// width: 5, -// ), -// GestureDetector( -// onTap: () { -// favProviderModel.add( -// Container( -// padding: const EdgeInsets.symmetric( -// horizontal: 12, -// vertical: 8, -// ), -// constraints: const BoxConstraints( -// minWidth: -// 400.0, // Set the minimum width constraint -// maxWidth: -// 500.0, // Set the maximum width constraint -// minHeight: -// 50.0, // Set the minimum height constraint -// maxHeight: -// 100.0, // Set the maximum height constraint -// ), -// child: basicbottomNavbar[index], -// ), -// ); -// setState(() { -// basicbottomNavbarColor[index] = -// Colors.amber; -// }); -// }, -// child: Icon( -// Icons.star_border_outlined, -// color: basicbottomNavbarColor[index], -// ), -// ), -// ], -// ), -// ), -// ], -// ), -// ), -// ), -// ), -// Align( -// alignment: Alignment.centerLeft, -// child: Padding( -// padding: const EdgeInsets.all(8.0), -// child: Text("Animated Bottom Nav-Bars", -// style: TextStyle( -// fontSize: 20, -// fontWeight: FontWeight.bold, -// color: MyTheme.lightBluishColor)), -// ), -// ), -// Wrap( -// direction: Axis.horizontal, -// children: List.generate( -// animatedbottomNavbar.length, -// (index) => Consumer( -// builder: (context, favProviderModel, child) => Column( -// children: [ -// Container( -// padding: const EdgeInsets.symmetric( -// horizontal: 12, -// vertical: 8, -// ), -// constraints: const BoxConstraints( -// minWidth: 400.0, // Set the minimum width constraint -// maxWidth: 500.0, // Set the maximum width constraint -// minHeight: -// 50.0, // Set the minimum height constraint -// maxHeight: -// 100.0, // Set the maximum height constraint -// ), -// child: animatedbottomNavbar[index], -// ), -// Padding( -// padding: const EdgeInsets.fromLTRB(0, 3, 20, 3), -// child: Row( -// mainAxisAlignment: MainAxisAlignment.end, -// crossAxisAlignment: CrossAxisAlignment.start, -// children: [ -// const Text('Add to favorite'), -// const SizedBox( -// width: 5, -// ), -// GestureDetector( -// onTap: () { -// favProviderModel.add( -// Container( -// padding: const EdgeInsets.symmetric( -// horizontal: 12, -// vertical: 8, -// ), -// constraints: const BoxConstraints( -// minWidth: -// 400.0, // Set the minimum width constraint -// maxWidth: -// 500.0, // Set the maximum width constraint -// minHeight: -// 50.0, // Set the minimum height constraint -// maxHeight: -// 100.0, // Set the maximum height constraint -// ), -// child: animatedbottomNavbar[index], -// ), -// ); -// setState(() { -// animatedbottomNavbarColor[index] = -// Colors.amber; -// }); -// }, -// child: Icon( -// Icons.star_border_outlined, -// color: animatedbottomNavbarColor[index], -// ), -// ), -// ], -// ), -// ), -// ], -// ), -// ), -// ), -// ), -// Align( -// alignment: Alignment.centerLeft, -// child: Padding( -// padding: const EdgeInsets.all(8.0), -// child: Text("FAB Bottom Nav-Bars", -// style: TextStyle( -// fontSize: 20, -// fontWeight: FontWeight.bold, -// color: MyTheme.lightBluishColor)), -// ), -// ), -// Wrap( -// direction: Axis.horizontal, -// children: List.generate( -// fabbottomNavbar.length, -// (index) => Consumer( -// builder: (context, favProviderModel, child) => Column( -// children: [ -// Container( -// padding: const EdgeInsets.symmetric( -// horizontal: 12, -// vertical: 8, -// ), -// constraints: const BoxConstraints( -// minWidth: 400.0, // Set the minimum width constraint -// maxWidth: 500.0, // Set the maximum width constraint -// minHeight: -// 50.0, // Set the minimum height constraint -// maxHeight: -// 100.0, // Set the maximum height constraint -// ), -// child: fabbottomNavbar[index], -// ), -// Padding( -// padding: const EdgeInsets.fromLTRB(0, 3, 20, 3), -// child: Row( -// mainAxisAlignment: MainAxisAlignment.end, -// crossAxisAlignment: CrossAxisAlignment.start, -// children: [ -// const Text('Add to favorite'), -// const SizedBox( -// width: 5, -// ), -// GestureDetector( -// onTap: () { -// favProviderModel.add( -// Container( -// padding: const EdgeInsets.symmetric( -// horizontal: 12, -// vertical: 8, -// ), -// constraints: const BoxConstraints( -// minWidth: -// 400.0, // Set the minimum width constraint -// maxWidth: -// 500.0, // Set the maximum width constraint -// minHeight: -// 50.0, // Set the minimum height constraint -// maxHeight: -// 100.0, // Set the maximum height constraint -// ), -// child: fabbottomNavbar[index], -// ), -// ); -// setState(() { -// fabbottomNavbarColor[index] = Colors.amber; -// }); -// }, -// child: Icon( -// Icons.star_border_outlined, -// color: fabbottomNavbarColor[index], -// ), -// ), -// ], -// ), -// ), -// ], -// ), -// ), -// ), -// ), -// ], -// ), -// ), -// ), -// ); -// } -// } + @override + Widget build(BuildContext context) { + return Scaffold( + body: SafeArea( + child: SingleChildScrollView( + child: Column( + // mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Align( + alignment: Alignment.centerLeft, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text("Basic Bottom Nav-Bars", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: MyTheme.lightBluishColor)), + ), + ), + Wrap( + direction: Axis.horizontal, + children: List.generate( + basicbottomNavbarIndex.length, + (index) => Consumer( + builder: (context, favProviderModel, child) => Column( + children: [ + Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), + constraints: const BoxConstraints( + minWidth: 400.0, // Set the minimum width constraint + maxWidth: 500.0, // Set the maximum width constraint + minHeight: + 50.0, // Set the minimum height constraint + maxHeight: + 100.0, // Set the maximum height constraint + ), + child: basicbottomNavbar[index], + ), + Padding( + padding: const EdgeInsets.fromLTRB(0, 3, 20, 3), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text('Add to favorite'), + const SizedBox( + width: 5, + ), + GestureDetector( + onTap: () { + favProviderModel + .add(basicbottomNavbarIndex[index]); + setState(() {}); + }, + child: Icon( + Icons.star_border_outlined, + color: (favProviderModel.starred( + basicbottomNavbarIndex[index])) + ? Colors.amber + : null, + ), + ), + ], + ), + ), + ], + ), + ), + ), + ), + Align( + alignment: Alignment.centerLeft, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text("Animated Bottom Nav-Bars", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: MyTheme.lightBluishColor)), + ), + ), + Wrap( + direction: Axis.horizontal, + children: List.generate( + animatedbottomNavbarIndex.length, + (index) => Consumer( + builder: (context, favProviderModel, child) => Column( + children: [ + Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), + constraints: const BoxConstraints( + minWidth: 400.0, // Set the minimum width constraint + maxWidth: 500.0, // Set the maximum width constraint + minHeight: + 50.0, // Set the minimum height constraint + maxHeight: + 100.0, // Set the maximum height constraint + ), + child: animatedbottomNavbar[index], + ), + Padding( + padding: const EdgeInsets.fromLTRB(0, 3, 20, 3), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text('Add to favorite'), + const SizedBox( + width: 5, + ), + GestureDetector( + onTap: () { + favProviderModel + .add(animatedbottomNavbarIndex[index]); + setState(() {}); + }, + child: Icon( + Icons.star_border_outlined, + color: (favProviderModel.starred( + animatedbottomNavbarIndex[index])) + ? Colors.amber + : null, + ), + ), + ], + ), + ), + ], + ), + ), + ), + ), + Align( + alignment: Alignment.centerLeft, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text("FAB Bottom Nav-Bars", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: MyTheme.lightBluishColor)), + ), + ), + Wrap( + direction: Axis.horizontal, + children: List.generate( + fabbottomNavbarIndex.length, + (index) => Consumer( + builder: (context, favProviderModel, child) => Column( + children: [ + Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), + constraints: const BoxConstraints( + minWidth: 400.0, // Set the minimum width constraint + maxWidth: 500.0, // Set the maximum width constraint + minHeight: + 50.0, // Set the minimum height constraint + maxHeight: + 100.0, // Set the maximum height constraint + ), + child: fabbottomNavbar[index], + ), + Padding( + padding: const EdgeInsets.fromLTRB(0, 3, 20, 3), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text('Add to favorite'), + const SizedBox( + width: 5, + ), + GestureDetector( + onTap: () { + favProviderModel + .add(fabbottomNavbarIndex[index]); + setState(() {}); + }, + child: Icon( + Icons.star_border_outlined, + color: (favProviderModel + .starred(fabbottomNavbarIndex[index])) + ? Colors.amber + : null, + ), + ), + ], + ), + ), + ], + ), + ), + ), + ), + ], + ), + ), + ), + ); + } +} From 82b370f8c799b9a0fb915c412410a3453d23a886 Mon Sep 17 00:00:00 2001 From: Uttkarsh-raj Date: Wed, 7 Jun 2023 15:06:37 +0530 Subject: [PATCH 4/4] some minor problems solved --- .../animated_navbar/bottom_navbar4.dart | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/ui_components/bottom_navbars/allBottomNavigationBars/animated_navbar/bottom_navbar4.dart b/lib/ui_components/bottom_navbars/allBottomNavigationBars/animated_navbar/bottom_navbar4.dart index 494b505..b9df01c 100644 --- a/lib/ui_components/bottom_navbars/allBottomNavigationBars/animated_navbar/bottom_navbar4.dart +++ b/lib/ui_components/bottom_navbars/allBottomNavigationBars/animated_navbar/bottom_navbar4.dart @@ -26,7 +26,7 @@ class Bottom_Navbar4State extends State { BoxShadow( color: Colors.black.withOpacity(.1), blurRadius: 30, - offset: Offset(0, 10), + offset: const Offset(0, 10), ), ], borderRadius: BorderRadius.circular(50), @@ -47,14 +47,14 @@ class Bottom_Navbar4State extends State { child: Stack( children: [ AnimatedContainer( - duration: Duration(seconds: 1), + duration: const Duration(seconds: 1), curve: Curves.fastLinearToSlowEaseIn, width: index == currentIndex ? displayWidth * .32 : displayWidth * .18, alignment: Alignment.center, child: AnimatedContainer( - duration: Duration(seconds: 1), + duration: const Duration(seconds: 1), curve: Curves.fastLinearToSlowEaseIn, height: index == currentIndex ? displayWidth * .12 : 0, width: index == currentIndex ? displayWidth * .32 : 0, @@ -78,19 +78,17 @@ class Bottom_Navbar4State extends State { Row( children: [ AnimatedContainer( - duration: Duration(seconds: 1), + duration: const Duration(seconds: 1), curve: Curves.fastLinearToSlowEaseIn, width: index == currentIndex ? displayWidth * .13 : 0, ), AnimatedOpacity( opacity: index == currentIndex ? 1 : 0, - duration: Duration(seconds: 1), + duration: const Duration(seconds: 1), curve: Curves.fastLinearToSlowEaseIn, child: Text( - index == currentIndex - ? '${listOfStrings[index]}' - : '', + index == currentIndex ? listOfStrings[index] : '', style: TextStyle( color: isDarkMode ? Colors.amberAccent @@ -105,7 +103,7 @@ class Bottom_Navbar4State extends State { Row( children: [ AnimatedContainer( - duration: Duration(seconds: 1), + duration: const Duration(seconds: 1), curve: Curves.fastLinearToSlowEaseIn, width: index == currentIndex ? displayWidth * .03 : 20,