-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f89c0ff
commit 1adc922
Showing
3 changed files
with
132 additions
and
109 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import '../../../model/menu.dart'; | ||
import '../../../utils/rive_utils.dart'; | ||
import 'info_card.dart'; | ||
import 'side_menu.dart'; | ||
|
||
class SideBar extends StatefulWidget { | ||
const SideBar({super.key}); | ||
|
||
@override | ||
State<SideBar> createState() => _SideBarState(); | ||
} | ||
|
||
class _SideBarState extends State<SideBar> { | ||
Menu selectedSideMenu = sidebarMenus.first; | ||
@override | ||
Widget build(BuildContext context) { | ||
return SafeArea( | ||
child: Container( | ||
width: 288, | ||
height: double.infinity, | ||
decoration: const BoxDecoration( | ||
color: Color(0xFF17203A), | ||
borderRadius: BorderRadius.all( | ||
Radius.circular(30), | ||
), | ||
), | ||
child: DefaultTextStyle( | ||
style: const TextStyle(color: Colors.white), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
const InfoCard( | ||
name: "Abu Anwar", | ||
bio: "YouTuber", | ||
), | ||
Padding( | ||
padding: const EdgeInsets.only(left: 24, top: 32, bottom: 16), | ||
child: Text( | ||
"Browse".toUpperCase(), | ||
style: Theme.of(context) | ||
.textTheme | ||
.titleMedium! | ||
.copyWith(color: Colors.white70), | ||
), | ||
), | ||
...sidebarMenus | ||
.map((menu) => SideMenu( | ||
menu: menu, | ||
selectedMenu: selectedSideMenu, | ||
press: () { | ||
RiveUtils.chnageSMIBoolState(menu.rive.status!); | ||
setState(() { | ||
selectedSideMenu = menu; | ||
}); | ||
}, | ||
riveOnInit: (artboard) { | ||
menu.rive.status = RiveUtils.getRiveInput(artboard, | ||
stateMachineName: menu.rive.stateMachineName); | ||
}, | ||
)) | ||
.toList(), | ||
Padding( | ||
padding: const EdgeInsets.only(left: 24, top: 40, bottom: 16), | ||
child: Text( | ||
"History".toUpperCase(), | ||
style: Theme.of(context) | ||
.textTheme | ||
.titleMedium! | ||
.copyWith(color: Colors.white70), | ||
), | ||
), | ||
...sidebarMenus2 | ||
.map((menu) => SideMenu( | ||
menu: menu, | ||
selectedMenu: selectedSideMenu, | ||
press: () { | ||
RiveUtils.chnageSMIBoolState(menu.rive.status!); | ||
setState(() { | ||
selectedSideMenu = menu; | ||
}); | ||
}, | ||
riveOnInit: (artboard) { | ||
menu.rive.status = RiveUtils.getRiveInput(artboard, | ||
stateMachineName: menu.rive.stateMachineName); | ||
}, | ||
)) | ||
.toList(), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
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,23 @@ | ||
import 'package:rive/rive.dart'; | ||
|
||
class RiveUtils { | ||
static SMIBool getRiveInput(Artboard artboard, | ||
{required String stateMachineName}) { | ||
StateMachineController? controller = | ||
StateMachineController.fromArtboard(artboard, stateMachineName); | ||
|
||
artboard.addController(controller!); | ||
|
||
return controller.findInput<bool>("active") as SMIBool; | ||
} | ||
|
||
static void chnageSMIBoolState(SMIBool input) { | ||
input.change(true); | ||
Future.delayed( | ||
const Duration(seconds: 1), | ||
() { | ||
input.change(false); | ||
}, | ||
); | ||
} | ||
} |