diff --git a/lib/users/Iuser.dart b/lib/users/Iuser.dart index 817904867..43fd19299 100644 --- a/lib/users/Iuser.dart +++ b/lib/users/Iuser.dart @@ -1,6 +1,27 @@ import 'package:flutter/cupertino.dart'; +import 'package:api_client/models/activity_model.dart'; +import 'package:api_client/models/displayname_model.dart'; +import 'package:api_client/models/enums/activity_state_enum.dart'; +import 'package:api_client/models/enums/complete_mark_enum.dart'; +import 'package:api_client/models/enums/default_timer_enum.dart'; +import 'package:api_client/models/pictogram_model.dart'; +import 'package:api_client/models/settings_model.dart'; +import 'package:flutter/material.dart'; +import 'package:weekplanner/blocs/auth_bloc.dart'; +import 'package:weekplanner/blocs/pictogram_image_bloc.dart'; +import 'package:weekplanner/blocs/settings_bloc.dart'; +import 'package:weekplanner/blocs/timer_bloc.dart'; +import 'package:weekplanner/models/enums/timer_running_mode.dart'; +import 'package:weekplanner/models/enums/weekplan_mode.dart'; +import 'package:weekplanner/widgets/pictogram_text.dart'; +import 'package:weekplanner/widgets/timer_widgets/timer_piechart.dart'; abstract class Iuser{ -Widget build_avatar_icon_behavior (); -Widget build_choice_board_behavior (); + Widget _buildActivityCard( + BuildContext context, + ActivityModel activity, + TimerBloc timerBloc, + DisplayNameModel user, + AsyncSnapshot weekModeSnapShot, + AsyncSnapshot settingsSnapShot); } \ No newline at end of file diff --git a/lib/users/citizen.dart b/lib/users/citizen.dart index 7bbb9fa0d..e1ba551bb 100644 --- a/lib/users/citizen.dart +++ b/lib/users/citizen.dart @@ -1,29 +1,31 @@ import 'package:flutter/material.dart'; -import 'package:weekplanner/Users/Iuser.dart'; +import 'package:weekplanner/users/Iuser.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:api_client/models/activity_model.dart'; +import 'package:api_client/models/displayname_model.dart'; +import 'package:api_client/models/enums/activity_state_enum.dart'; +import 'package:api_client/models/enums/complete_mark_enum.dart'; +import 'package:api_client/models/enums/default_timer_enum.dart'; +import 'package:api_client/models/pictogram_model.dart'; +import 'package:api_client/models/settings_model.dart'; +import 'package:flutter/material.dart'; +import 'package:weekplanner/blocs/auth_bloc.dart'; +import 'package:weekplanner/blocs/pictogram_image_bloc.dart'; +import 'package:weekplanner/blocs/settings_bloc.dart'; +import 'package:weekplanner/blocs/timer_bloc.dart'; +import 'package:weekplanner/models/enums/timer_running_mode.dart'; +import 'package:weekplanner/models/enums/weekplan_mode.dart'; +import 'package:weekplanner/widgets/pictogram_text.dart'; +import 'package:weekplanner/widgets/timer_widgets/timer_piechart.dart'; + +class citizen implements Iuser{ + + -class citizen implements IUser{ - @override - Widget build_avatar_icon_behavior(BuildContext context){ - return Container( - width: 400, - height: 400, - child: Container( - margin: EdgeInsets.all(MediaQuery.of(context).size.width * 0.02), - child: const CircleAvatar( - key: Key('PlaceholderAvatar'), - radius: 20, - backgroundImage: AssetImage('assets/login_screen_background_image.png'), - ), - ), - ); +} - } - @override - Widget build_choice_board_behavior (){ - } -} \ No newline at end of file diff --git a/lib/users/guardian.dart b/lib/users/guardian.dart index c80f2defc..a0a90ba97 100644 --- a/lib/users/guardian.dart +++ b/lib/users/guardian.dart @@ -1,10 +1,22 @@ import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; import 'package:weekplanner/Users/Iuser.dart'; -class guardian implements IUser{ +class guardian implements Iuser{ @override - Widget build_avatar_icon_behavior(){ - + Widget build_avatar_icon_behavior (BuildContext context) { + return Container( + width: 400, + height: 400, + child: Container( + margin: EdgeInsets.all(MediaQuery.of(context).size.width * 0.02), + child: const CircleAvatar( + key: Key('PlaceholderAvatar'), + radius: 20, + backgroundImage: AssetImage('assets/login_screen_background_image.png'), + ), + ), + ); } @override Widget build_choice_board_behavior (){ diff --git a/lib/users/superuser.dart b/lib/users/superuser.dart index b7f2151eb..a11073d4c 100644 --- a/lib/users/superuser.dart +++ b/lib/users/superuser.dart @@ -1,10 +1,24 @@ import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; import 'package:weekplanner/Users/Iuser.dart'; -class superuser implements IUser{ - @override - Widget build_avatar_icon_behavior(){ +import 'Iuser.dart'; +class superuser implements Iuser{ + @override + Widget build_avatar_icon_behavior (BuildContext context) { + return Container( + width: 400, + height: 400, + child: Container( + margin: EdgeInsets.all(MediaQuery.of(context).size.width * 0.02), + child: const CircleAvatar( + key: Key('PlaceholderAvatar'), + radius: 20, + backgroundImage: AssetImage('assets/login_screen_background_image.png'), + ), + ), + ); } @override Widget build_choice_board_behavior (){ diff --git a/lib/users/trustee.dart b/lib/users/trustee.dart index e0bf4d37b..ca38bc8b7 100644 --- a/lib/users/trustee.dart +++ b/lib/users/trustee.dart @@ -1,10 +1,24 @@ import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; import 'package:weekplanner/Users/Iuser.dart'; -class trustee implements IUser{ - @override - Widget build_avatar_icon_behavior(){ +import 'Iuser.dart'; +class trustee implements Iuser{ + @override + Widget build_avatar_icon_behavior (BuildContext context) { + return Container( + width: 400, + height: 400, + child: Container( + margin: EdgeInsets.all(MediaQuery.of(context).size.width * 0.02), + child: const CircleAvatar( + key: Key('PlaceholderAvatar'), + radius: 20, + backgroundImage: AssetImage('assets/login_screen_background_image.png'), + ), + ), + ); } @override Widget build_choice_board_behavior (){ diff --git a/lib/widgets/weekplan_screen_widgets/activity_card.dart b/lib/widgets/weekplan_screen_widgets/activity_card.dart index ac47d90e7..33df752c0 100644 --- a/lib/widgets/weekplan_screen_widgets/activity_card.dart +++ b/lib/widgets/weekplan_screen_widgets/activity_card.dart @@ -83,7 +83,7 @@ class ActivityCard extends StatelessWidget { Stack( alignment: AlignmentDirectional.topStart, children: [ - _buildAvatarIcon(context,weekModeSnapShot.data), + _buildAvatarIcon(context), ], ), ], @@ -129,54 +129,67 @@ class ActivityCard extends StatelessWidget { ), ); } + // Check if there is more than one activity in the choiceboard + final bool multipleActivities = + _activity.pictograms.length > 1 && _activity.isChoiceBoard; 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: [ - Stack( - children: [ - Stack( - alignment: AlignmentDirectional.topEnd, - children: [ - SizedBox( - width: MediaQuery.of(context).size.width, - height: MediaQuery.of(context).size.width, - child: FittedBox( - child: Stack( - alignment: AlignmentDirectional.center, - children: [ - SizedBox( - key: const Key('WeekPlanScreenChoiceBoard'), - width: MediaQuery.of(context).size.width, - height: MediaQuery.of(context).size.width, - child: returnGridView(pictograms)), - ], - )), + 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: [ + Stack( + children: [ + Stack( + alignment: AlignmentDirectional.topEnd, + children: [ + SizedBox( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.width, + child: FittedBox( + child: Stack( + alignment: AlignmentDirectional.center, + children: [ + 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: [ - _buildAvatarIcon(context,weekModeSnapShot.data), - ]) - ], - ), - PictogramText(_activity, _user), - ], - ), - )); + ), + _buildActivityStateIcon( + context, _activityState, weekModeSnapShot, settingsSnapShot), + _buildTimerIcon(context, _activity), + ], + ), + // Remove avatar icon if there are multiple activities in the choiceboard + multipleActivities == false + ? Stack( + alignment: AlignmentDirectional.topStart, + children: [ + _buildAvatarIcon(context), + ], + ) + : Container(), + ], + ), + PictogramText(_activity, _user), + ], + ), + ), + ); } + ///Returns the correct gridview Center returnGridView(List list) { return Center( @@ -397,24 +410,19 @@ class ActivityCard extends StatelessWidget { }); } - Widget _buildAvatarIcon(BuildContext context, WeekplanMode userRole) { - if (userRole == WeekplanMode.guardian || userRole == WeekplanMode.trustee) { - return Container( + + Widget _buildAvatarIcon(BuildContext context) { + return Container( width: 400, height: 400, child: Container( margin: EdgeInsets.all(MediaQuery.of(context).size.width * 0.02), child: const CircleAvatar( - key: Key('PlaceholderAvatar'), - radius: 20, - backgroundImage: AssetImage('assets/login_screen_background_image.png'), - ), - ), - ); - } else { - return Container(); // Return an empty container when - // the role is "citizen." - } + key: Key('PlaceholderAvatar'), + radius: 20, + backgroundImage: + AssetImage('assets/login_screen_background_image.png')), + )); } }