Skip to content

Commit

Permalink
Merge pull request #13 from Ashhas/develop_branch
Browse files Browse the repository at this point in the history
pullrequest version 0.6.7
  • Loading branch information
Ashhas authored Aug 20, 2021
2 parents d464c82 + 61d5138 commit 2fbae88
Show file tree
Hide file tree
Showing 18 changed files with 155 additions and 197 deletions.
15 changes: 13 additions & 2 deletions lib/bloc/add_weight/add_weight_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,19 @@ class AddWeightBloc extends Bloc<AddWeightEvent, AddWeightState> {

Stream<AddWeightState> _mapAddNewMeasurementToState(
DateTime measurementDate, String measurementInput) async* {
await measurementRepository.setNewMeasurement(
MeasurementModel(measurementDate, double.parse(measurementInput)));
if (isToday(measurementDate)) {
await measurementRepository.setNewMeasurement(
MeasurementModel(DateTime.now(), double.parse(measurementInput)));
} else {
await measurementRepository.setNewMeasurement(
MeasurementModel(measurementDate, double.parse(measurementInput)));
}
}

bool isToday(DateTime dateToCheck) {
return DateTime.now().year == dateToCheck.year &&
DateTime.now().month == dateToCheck.month &&
DateTime.now().day == dateToCheck.day;
}

@override
Expand Down
20 changes: 17 additions & 3 deletions lib/ui/add_weight/add_weight_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,14 @@ class _AddWeightScreenState extends State<AddWeightScreen> {
headerStyle: HeaderStyle(
titleCentered: true,
formatButtonVisible: false,
titleTextStyle:
Theme.of(context).primaryTextTheme.bodyText2,
),
daysOfWeekStyle: DaysOfWeekStyle(
weekendStyle: TextStyle(color: Colors.black),
weekdayStyle:
Theme.of(context).primaryTextTheme.bodyText1,
weekendStyle:
Theme.of(context).primaryTextTheme.bodyText1,
),
calendarStyle: CalendarStyle(
outsideDaysVisible: false,
Expand All @@ -77,11 +82,14 @@ class _AddWeightScreenState extends State<AddWeightScreen> {
color: Colors.green, shape: BoxShape.circle),
todayDecoration:
BoxDecoration(color: Theme.of(context).primaryColor),
weekendTextStyle: TextStyle(color: Colors.black),
defaultTextStyle:
Theme.of(context).primaryTextTheme.bodyText1,
weekendTextStyle:
Theme.of(context).primaryTextTheme.bodyText1,
),
onDaySelected: _onDaySelected,
enabledDayPredicate: (day) {
if (DateTime.now().isAfter(day)) {
if (DateTime.now().isAfter(day) || isToday(day)) {
return true;
} else {
return false;
Expand Down Expand Up @@ -131,4 +139,10 @@ class _AddWeightScreenState extends State<AddWeightScreen> {
},
);
}

bool isToday(DateTime dateToCheck) {
return DateTime.now().year == dateToCheck.year &&
DateTime.now().month == dateToCheck.month &&
DateTime.now().day == dateToCheck.day;
}
}
4 changes: 2 additions & 2 deletions lib/ui/add_weight/widgets/add_weight_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class _AddWeightDialogState extends State<AddWeightDialog> {
(new DateFormat.yMMMd('en_US')
.format(widget.selectedDay)
.toString()),
style: Theme.of(context).textTheme.bodyText1,
style: Theme.of(context).primaryTextTheme.bodyText2,
)),
Divider(),
Padding(
Expand All @@ -49,7 +49,7 @@ class _AddWeightDialogState extends State<AddWeightDialog> {
children: [
Text(
"Add Weight",
style: Theme.of(context).textTheme.subtitle1,
style: Theme.of(context).primaryTextTheme.bodyText2,
),
TextFormField(
controller: textFormController,
Expand Down
24 changes: 4 additions & 20 deletions lib/ui/dashboard/widgets/current_weight_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,38 +45,22 @@ class _CurrentWeightWidgetState extends State<CurrentWeightWidget>
state.measurement != null
? Text(
state.measurement.weightEntry.toString(),
style: TextStyle(
fontSize: 25,
color: Colors.white,
fontWeight: FontWeight.w800,
),
style: Theme.of(context).primaryTextTheme.headline1,
)
: Text(
" - ",
style: TextStyle(
fontSize: 25,
color: Colors.white,
fontWeight: FontWeight.w800,
),
style: Theme.of(context).primaryTextTheme.headline1
),
SizedBox(width: 4),
Text(
state.unitType,
style: TextStyle(
fontSize: 15,
color: Colors.white.withOpacity(0.6),
fontWeight: FontWeight.w800,
),
style: Theme.of(context).primaryTextTheme.headline4
),
],
),
Text(
UiConst.weightCurrentTitle,
style: TextStyle(
fontSize: 15,
color: Colors.white,
fontWeight: FontWeight.w500,
),
style: Theme.of(context).primaryTextTheme.subtitle1
),
],
),
Expand Down
18 changes: 3 additions & 15 deletions lib/ui/dashboard/widgets/start_weight_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,18 @@ class _StartWeightWidgetState extends State<StartWeightWidget> {
children: [
Text(
state.startWeight.toString(),
style: TextStyle(
fontSize: 20,
color: Colors.white,
fontWeight: FontWeight.w800,
),
style: Theme.of(context).primaryTextTheme.headline2
),
SizedBox(width: 4),
Text(
state.unitType,
style: TextStyle(
fontSize: 15,
color: Colors.white.withOpacity(0.6),
fontWeight: FontWeight.w800,
),
style: Theme.of(context).primaryTextTheme.headline4
),
],
),
Text(
UiConst.weightStartedTitle,
style: TextStyle(
fontSize: 15,
color: Colors.white,
fontWeight: FontWeight.w500,
),
style: Theme.of(context).primaryTextTheme.subtitle1
),
],
),
Expand Down
30 changes: 6 additions & 24 deletions lib/ui/dashboard/widgets/target_weight_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,15 @@ class _TargetWeightWidgetState extends State<TargetWeightWidget> {
children: [
Row(
children: [
Text(
state.targetWeight.toString(),
style: TextStyle(
fontSize: 20,
color: Colors.white,
fontWeight: FontWeight.w800,
),
),
Text(state.targetWeight.toString(),
style: Theme.of(context).primaryTextTheme.headline2),
SizedBox(width: 4),
Text(
state.unitType,
style: TextStyle(
fontSize: 15,
color: Colors.white.withOpacity(0.6),
fontWeight: FontWeight.w800,
),
),
Text(state.unitType,
style: Theme.of(context).primaryTextTheme.headline4),
],
),
Text(
UiConst.weightTargetTitle,
style: TextStyle(
fontSize: 15,
color: Colors.white,
fontWeight: FontWeight.w500,
),
),
Text(UiConst.weightTargetTitle,
style: Theme.of(context).primaryTextTheme.subtitle1),
],
),
);
Expand Down
28 changes: 10 additions & 18 deletions lib/ui/dashboard/widgets/weight_stats_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class _WeightStatsWidgetState extends State<WeightStatsWidget> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(titleName,
style: Theme.of(context).primaryTextTheme.headline6),
style: Theme.of(context).primaryTextTheme.headline3),
],
),
),
Expand All @@ -94,13 +94,13 @@ class _WeightStatsWidgetState extends State<WeightStatsWidget> {
percentageCompleted != null
? (percentageCompleted * 100).round().toString()
: "-",
style: Theme.of(context).primaryTextTheme.bodyText2),
style: Theme.of(context).primaryTextTheme.headline5),
Text("%",
style: Theme.of(context).primaryTextTheme.bodyText2),
style: Theme.of(context).primaryTextTheme.subtitle2),
],
),
Text("Completed",
style: Theme.of(context).primaryTextTheme.bodyText2),
style: Theme.of(context).primaryTextTheme.subtitle2),
],
),
Divider(),
Expand All @@ -109,20 +109,16 @@ class _WeightStatsWidgetState extends State<WeightStatsWidget> {
Row(
children: [
Text(totalLost != null ? totalLost.toStringAsFixed(2) : "-",
style: Theme.of(context).primaryTextTheme.bodyText2),
style: Theme.of(context).primaryTextTheme.headline5),
SizedBox(width: 4),
Text(
unitType,
style: TextStyle(
fontSize: 15,
color: Colors.grey,
fontWeight: FontWeight.w800,
),
style: Theme.of(context).primaryTextTheme.headline4,
),
],
),
Text("Total Lost",
style: Theme.of(context).primaryTextTheme.bodyText2),
style: Theme.of(context).primaryTextTheme.subtitle2),
],
),
Divider(),
Expand All @@ -131,20 +127,16 @@ class _WeightStatsWidgetState extends State<WeightStatsWidget> {
Row(
children: [
Text(amountLeft != null ? amountLeft.toStringAsFixed(2) : "-",
style: Theme.of(context).primaryTextTheme.bodyText2),
style: Theme.of(context).primaryTextTheme.headline5),
SizedBox(width: 4),
Text(
unitType,
style: TextStyle(
fontSize: 15,
color: Colors.grey,
fontWeight: FontWeight.w800,
),
style: Theme.of(context).primaryTextTheme.headline4,
),
],
),
Text("Left to Go",
style: Theme.of(context).primaryTextTheme.bodyText2),
style: Theme.of(context).primaryTextTheme.subtitle2),
],
),
],
Expand Down
24 changes: 9 additions & 15 deletions lib/ui/history/history_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class _HistoryScreenState extends State<HistoryScreen> {
child: Text("No weight entry added in this month!",
textAlign: TextAlign.center,
style:
TextStyle(color: Colors.black, fontSize: 16)),
Theme.of(context).primaryTextTheme.subtitle2),
),
);
} else {
Expand Down Expand Up @@ -94,7 +94,7 @@ class _HistoryScreenState extends State<HistoryScreen> {
),
Text(
DateFormat.yMMMM().format(_currentMonth),
style: TextStyle(fontSize: 18.0, color: Colors.white),
style: Theme.of(context).primaryTextTheme.subtitle1,
),
IconButton(
icon: Icon(Icons.chevron_right, color: Colors.white),
Expand Down Expand Up @@ -122,7 +122,7 @@ class _HistoryScreenState extends State<HistoryScreen> {
? Center(
child: Text("No weight entry added in this month!",
textAlign: TextAlign.center,
style: TextStyle(color: Colors.black, fontSize: 16)),
style: Theme.of(context).primaryTextTheme.subtitle2),
)
: ListView(
children: _sameMonthEventsFilter
Expand Down Expand Up @@ -150,20 +150,14 @@ class _HistoryScreenState extends State<HistoryScreen> {
DateFormat.yMMMMd('en_US')
.format(event.dateAdded)
.toString(),
style: TextStyle(
fontSize: 15,
color: Colors.black,
fontFamily: "Roboto",
fontWeight: FontWeight.w400,
)),
style: Theme.of(context)
.primaryTextTheme
.bodyText1),
Text(
event.weightEntry.toString(),
style: TextStyle(
fontSize: 18,
color: Colors.black,
fontFamily: "Roboto",
fontWeight: FontWeight.w900,
),
style: Theme.of(context)
.primaryTextTheme
.subtitle2,
)
],
),
Expand Down
8 changes: 4 additions & 4 deletions lib/ui/settings/screens/about_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class _AboutScreenState extends State<AboutScreen> {
children: [
SettingsTile(
title: "Github",
titleTextStyle: Theme.of(context).primaryTextTheme.headline4,
titleTextStyle: Theme.of(context).primaryTextTheme.bodyText2,
leading: Icon(Icons.developer_board_outlined, color: Colors.grey),
onPressed: (BuildContext context) {
_launchURL();
Expand All @@ -34,14 +34,14 @@ class _AboutScreenState extends State<AboutScreen> {
Divider(height: 1, thickness: 1),
SettingsTile(
title: "Version",
titleTextStyle: Theme.of(context).primaryTextTheme.headline4,
titleTextStyle: Theme.of(context).primaryTextTheme.bodyText2,
subtitle: widget.appVersion,
subtitleTextStyle: Theme.of(context).primaryTextTheme.subtitle1,
subtitleTextStyle: Theme.of(context).primaryTextTheme.subtitle2,
onPressed: (BuildContext context) {},
),
SettingsTile(
title: "Open-source licenses",
titleTextStyle: Theme.of(context).primaryTextTheme.headline4,
titleTextStyle: Theme.of(context).primaryTextTheme.bodyText2,
onPressed: (BuildContext context) {},
),
],
Expand Down
18 changes: 6 additions & 12 deletions lib/ui/settings/screens/goal_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ class _GoalScreenState extends State<GoalScreen> {
SettingsTile(
title: "Start Weight",
titleTextStyle:
Theme.of(context).primaryTextTheme.headline4,
subtitleTextStyle:
Theme.of(context).primaryTextTheme.subtitle1,
Theme.of(context).primaryTextTheme.bodyText2,
trailing: Text(state.startWeight.toString(),
style: Theme.of(context).primaryTextTheme.subtitle1),
style: Theme.of(context).primaryTextTheme.bodyText2),
onPressed: (BuildContext context) {
showDialog(
context: context,
Expand All @@ -55,22 +53,18 @@ class _GoalScreenState extends State<GoalScreen> {
SettingsTile(
title: "Current Weight",
titleTextStyle:
Theme.of(context).primaryTextTheme.headline4,
subtitleTextStyle:
Theme.of(context).primaryTextTheme.subtitle1,
Theme.of(context).primaryTextTheme.bodyText2,
trailing: Text(state.currentWeight.toString(),
style: Theme.of(context).primaryTextTheme.subtitle1),
style: Theme.of(context).primaryTextTheme.bodyText2),
onPressed: (BuildContext context) {},
),
Divider(height: 1, thickness: 1),
SettingsTile(
title: "Goal Weight",
titleTextStyle:
Theme.of(context).primaryTextTheme.headline4,
subtitleTextStyle:
Theme.of(context).primaryTextTheme.subtitle1,
Theme.of(context).primaryTextTheme.bodyText2,
trailing: Text(state.targetWeight.toString(),
style: Theme.of(context).primaryTextTheme.subtitle1),
style: Theme.of(context).primaryTextTheme.bodyText2),
onPressed: (BuildContext context) {
showDialog(
context: context,
Expand Down
Loading

0 comments on commit 2fbae88

Please sign in to comment.