Skip to content

Commit

Permalink
Merge branch 'develop' into Issue942
Browse files Browse the repository at this point in the history
  • Loading branch information
Thuyhaile authored Nov 13, 2023
2 parents 158d8cb + b4ae4e6 commit 442d809
Show file tree
Hide file tree
Showing 4 changed files with 850 additions and 811 deletions.
200 changes: 109 additions & 91 deletions lib/widgets/weekplan_screen_widgets/activity_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import '../../style/custom_color.dart' as theme;
/// Widget used for activities in the weekplan screen.
class ActivityCard extends StatelessWidget {
/// Constructor
ActivityCard(this._activity,this._timerBloc, this._user) {
ActivityCard(this._activity, this._timerBloc, this._user) {
_settingsBloc.loadSettings(_user);
}

Expand Down Expand Up @@ -129,52 +129,98 @@ class ActivityCard extends StatelessWidget {
),
);
}
return Container(
decoration: BoxDecoration(

if (_activity.chosenActivity != -1 &&
weekModeSnapShot.data != WeekplanMode.guardian) {
return Opacity(
opacity: _shouldActivityBeVisible(weekModeSnapShot, settingsSnapShot)
? 1.0
: 0,
child: Container(
color: theme.GirafColors.white,
border: Border.all(
color: Colors.black,
width: MediaQuery.of(context).size.width * 0.01)),
margin: EdgeInsets.all(MediaQuery.of(context).size.width * 0.02),
child: FittedBox(
child: Column(
children: <Widget>[
Stack(
margin: EdgeInsets.all(MediaQuery.of(context).size.width * 0.02),
child: FittedBox(
child: Column(
children: <Widget>[
Stack(
alignment: AlignmentDirectional.topEnd,
children: <Widget>[
SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.width,
child: FittedBox(
child: Stack(
alignment: AlignmentDirectional.center,
children: <Widget>[
SizedBox(
key: const Key('WeekPlanScreenChoiceBoard'),
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.width,
child: returnGridView(pictograms)),
],
)),
Stack(
alignment: AlignmentDirectional.topEnd,
children: <Widget>[
SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.width,
child: FittedBox(
child: _getPictogram(_activity
.pictograms[_activity.chosenActivity]),
),
),
_buildActivityStateIcon(context, _activityState,
weekModeSnapShot, settingsSnapShot),
_buildTimerIcon(context, _activity),
],
),
Stack(
alignment: AlignmentDirectional.topStart,
children: <Widget>[
_buildAvatarIcon(context),
],
),
_buildActivityStateIcon(context, _activityState,
weekModeSnapShot, settingsSnapShot),
_buildTimerIcon(context, _activity),
],
),
Stack(
alignment: AlignmentDirectional.topStart,
children: <Widget>[
_buildAvatarIcon(context),
])
PictogramText(_activity, _user),
],
),
PictogramText(_activity, _user),
],
),
));
)),
);
} else {
return Container(
decoration: BoxDecoration(
color: theme.GirafColors.white,
border: Border.all(
color: Colors.black,
width: MediaQuery.of(context).size.width * 0.01)),
margin: EdgeInsets.all(MediaQuery.of(context).size.width * 0.02),
child: FittedBox(
child: Column(
children: <Widget>[
Stack(
children: <Widget>[
Stack(
alignment: AlignmentDirectional.topEnd,
children: <Widget>[
SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.width,
child: FittedBox(
child: Stack(
alignment: AlignmentDirectional.center,
children: <Widget>[
SizedBox(
key: const Key('WeekPlanScreenChoiceBoard'),
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.width,
child: returnGridView(pictograms)),
],
)),
),
_buildActivityStateIcon(context, _activityState,
weekModeSnapShot, settingsSnapShot),
_buildTimerIcon(context, _activity),
],
),
Stack(
alignment: AlignmentDirectional.topStart,
children: <Widget>[
_buildAvatarIcon(context),
])
],
),
PictogramText(_activity, _user),
],
),
));
}
}

///Returns the correct gridview
Expand Down Expand Up @@ -225,8 +271,8 @@ class ActivityCard extends StatelessWidget {
AsyncSnapshot<SettingsModel> settingsSnapShot) {
return StreamBuilder<TimerRunningMode>(
stream: _timerBloc.timerRunningMode,
builder: (BuildContext context,
AsyncSnapshot<TimerRunningMode> snapshot1) {
builder:
(BuildContext context, AsyncSnapshot<TimerRunningMode> snapshot1) {
if (weekModeSnapShot.hasData && settingsSnapShot.hasData) {
final WeekplanMode role = weekModeSnapShot.data;
final SettingsModel settings = settingsSnapShot.data;
Expand All @@ -237,25 +283,17 @@ class ActivityCard extends StatelessWidget {
snapshot1.data != TimerRunningMode.running) {
break;
}
return Container(child: TimerPiechart(_timerBloc),
width: MediaQuery
.of(context)
.size
.width,
height: MediaQuery
.of(context)
.size
.height);
return Container(
child: TimerPiechart(_timerBloc),
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height);
case ActivityState.Completed:
if (role == WeekplanMode.guardian) {
return Icon(
Icons.check,
key: const Key('IconComplete'),
color: theme.GirafColors.green,
size: MediaQuery
.of(context)
.size
.width,
size: MediaQuery.of(context).size.width,
);
} else if (role == WeekplanMode.citizen) {
if (settings.completeMark == null) {
Expand All @@ -267,23 +305,14 @@ class ActivityCard extends StatelessWidget {
Icons.check,
key: const Key('IconComplete'),
color: theme.GirafColors.green,
size: MediaQuery
.of(context)
.size
.width,
size: MediaQuery.of(context).size.width,
);
} else if (settings.completeMark == CompleteMark.MovedRight) {
return Container(
key: const Key('GreyOutBox'),
color: theme.GirafColors.transparentGrey,
height: MediaQuery
.of(context)
.size
.width,
width: MediaQuery
.of(context)
.size
.width);
height: MediaQuery.of(context).size.width,
width: MediaQuery.of(context).size.width);
} else if (settings.completeMark == CompleteMark.Removed) {
//This case should be handled by _shouldActivityBeVisiblei
return Container(
Expand All @@ -293,17 +322,13 @@ class ActivityCard extends StatelessWidget {
}
}


return const Center(child: CircularProgressIndicator());
case ActivityState.Canceled:
return Icon(
Icons.clear,
key: const Key('IconCanceled'),
color: theme.GirafColors.red,
size: MediaQuery
.of(context)
.size
.width,
size: MediaQuery.of(context).size.width,
);
break;
case ActivityState.Active:
Expand All @@ -313,10 +338,7 @@ class ActivityCard extends StatelessWidget {
Icons.brightness_1_outlined,
key: const Key('IconActive'),
color: theme.GirafColors.amber,
size: MediaQuery
.of(context)
.size
.width,
size: MediaQuery.of(context).size.width,
);
}
if (role == WeekplanMode.citizen &&
Expand All @@ -325,10 +347,7 @@ class ActivityCard extends StatelessWidget {
Icons.brightness_1_outlined,
key: const Key('IconActive'),
color: theme.GirafColors.amber,
size: MediaQuery
.of(context)
.size
.width,
size: MediaQuery.of(context).size.width,
);
} else {
return Container(
Expand All @@ -337,21 +356,20 @@ class ActivityCard extends StatelessWidget {
);
}

break;
default:
break;
default:
return Container(
width: 0,
height: 0,
);
}
}
//If no settings/role have been loaded then we just make an empty overlay
return Container(
width: 0,
height: 0
,
width: 0,
height: 0,
);
}
}
//If no settings/role have been loaded then we just make an empty overlay
return Container(
width: 0,
height: 0,
);
});
});
}

Widget _buildTimerIcon(BuildContext context, ActivityModel activity) {
Expand Down
Loading

0 comments on commit 442d809

Please sign in to comment.