Skip to content

Instantly share code, notes, and snippets.

@thanhit93
Created May 13, 2021 11:07
Show Gist options
  • Save thanhit93/77289fe2257bd2fb28bcfb1443d61b1b to your computer and use it in GitHub Desktop.
Save thanhit93/77289fe2257bd2fb28bcfb1443d61b1b to your computer and use it in GitHub Desktop.
Widget _buildProgressBarPoint() {
return SizedBox(
height: 120,
child: StreamBuilder<int>(
stream: bloc.pointsBloc.stream,
initialData: 0,
builder: (context, snapshot) {
int points = snapshot.data;
return ListView.separated(
padding: const EdgeInsets.symmetric(horizontal: 50),
scrollDirection: Axis.horizontal,
itemCount: 4,
separatorBuilder: (BuildContext context, int index) => SizedBox(width: 8),
itemBuilder: (_, index) {
String pathIcon = 'ic_gift_grey';
if (index == 1) {
pathIcon = 'ic_gift_blue';
}
if (index == 2) {
pathIcon = 'ic_gift_yellow';
}
Widget progressView;
switch (index) {
case 0:
progressView = Container(
width: (points > 2000 ? 2000 : points) * 126 / 2000.0,
height: 24,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4.0),
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [ColorDefine.blue0_104, ColorDefine.blue54],
),
),
);
break;
case 1:
if (points <= 2000) {
progressView = SizedBox();
} else {
progressView = Container(
width: (points - (index * 2000)) * 126 / 2000.0,
height: 24,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4.0),
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [ColorDefine.blue0_104, ColorDefine.blue54],
),
),
);
}
break;
case 2:
if (points <= 4000) {
progressView = SizedBox();
} else {
progressView = Container(
width: (points - (index * 2000)) * 126 / 2000.0,
height: 24,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4.0),
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [ColorDefine.blue0_104, ColorDefine.blue54],
),
),
);
}
break;
case 3:
if (points <= 6000) {
progressView = SizedBox();
} else {
progressView = Container(
width: (points - (index * 2000)) * 126 / 2000.0,
height: 24,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4.0),
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [ColorDefine.blue0_104, ColorDefine.blue54],
),
),
);
}
break;
}
return SizedBox(
width: 126,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Align(
widthFactor: 0,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Container(
width: 30,
height: 30,
alignment: Alignment.center,
child: Image.asset(Utils.setPathImage('$pathIcon.png'), width: 25.0, height: 25.0),
),
Text('${index * 2000}'),
Icon(Icons.arrow_drop_down),
],
),
),
),
Stack(
children: [
Container(
height: 24,
color: ColorDefine.gray242,
),
progressView,
],
),
],
),
);
},
);
},
),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment