Last active
July 24, 2019 20:05
-
-
Save VB10/eb3e8856dcf3cc1610bb7b59e313c5fb to your computer and use it in GitHub Desktop.
Heltho UI Goal View dart
This file contains hidden or 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
int _selectCardIndex = 0; | |
List<String> goalCardList; | |
@override | |
void initState() { | |
super.initState(); | |
goalCardList = []; | |
goalCardList.add("Fat Loss"); | |
goalCardList.add("Weight Gain"); | |
goalCardList.add("Muscle Gain"); | |
goalCardList.add("Others"); | |
} | |
@override | |
Widget build(BuildContext context) { | |
ScreenUtil().init(context); | |
return Scaffold( | |
body: Padding( | |
padding: EdgeInsets.symmetric(horizontal: UIHelper.Space20), | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: <Widget>[ | |
Spacer(), | |
_titleTextStyle, | |
Expanded(flex: 4, child: _goalCardList), | |
], | |
)), | |
); | |
} | |
Widget get _goalCardList => ListView.builder( | |
itemCount: goalCardList.length, | |
itemBuilder: (context, index) => | |
_cardGoalItem(goalCardList[index], index), | |
); | |
Widget _cardGoalItem(String text, int index) => Card( | |
color: goalCardRaisedColor, | |
shape: goalCardInputDecoration, | |
child: ListTile( | |
onTap: () => _cardOnTap(index), | |
leading: CircleAvatar( | |
radius: UIHelper.Space14, | |
backgroundColor: _backgroundColor(index), | |
), | |
title: Text(text), | |
), | |
); | |
Widget get _titleTextStyle => Text( | |
"Select Your Goal", | |
style: userRegisterPageTitleStyle, | |
); | |
void _cardOnTap(int index) { | |
setState(() { | |
_selectCardIndex = index; | |
}); | |
} | |
Color _backgroundColor(int index) => _selectCardIndex == index | |
? phoneVerifyButtonColor | |
: Colors.grey[UIHelper.Space300.toInt()]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment