Skip to content

Commit

Permalink
Base of strategy pattern1
Browse files Browse the repository at this point in the history
  • Loading branch information
bafinouri91 committed Nov 13, 2023
1 parent 32acb26 commit 7c8d6a8
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 90 deletions.
25 changes: 23 additions & 2 deletions lib/users/Iuser.dart
Original file line number Diff line number Diff line change
@@ -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<WeekplanMode> weekModeSnapShot,
AsyncSnapshot<SettingsModel> settingsSnapShot);
}
44 changes: 23 additions & 21 deletions lib/users/citizen.dart
Original file line number Diff line number Diff line change
@@ -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 (){


}



}
18 changes: 15 additions & 3 deletions lib/users/guardian.dart
Original file line number Diff line number Diff line change
@@ -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 (){
Expand Down
20 changes: 17 additions & 3 deletions lib/users/superuser.dart
Original file line number Diff line number Diff line change
@@ -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 (){
Expand Down
20 changes: 17 additions & 3 deletions lib/users/trustee.dart
Original file line number Diff line number Diff line change
@@ -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 (){
Expand Down
124 changes: 66 additions & 58 deletions lib/widgets/weekplan_screen_widgets/activity_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class ActivityCard extends StatelessWidget {
Stack(
alignment: AlignmentDirectional.topStart,
children: <Widget>[
_buildAvatarIcon(context,weekModeSnapShot.data),
_buildAvatarIcon(context),
],
),
],
Expand Down Expand Up @@ -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: <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)),
],
)),
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,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: <Widget>[
_buildAvatarIcon(context),
],
)
: Container(),
],
),
PictogramText(_activity, _user),
],
),
),
);
}


///Returns the correct gridview
Center returnGridView(List<Widget> list) {
return Center(
Expand Down Expand Up @@ -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')),
));
}

}

0 comments on commit 7c8d6a8

Please sign in to comment.