Skip to content

Commit

Permalink
New update for Issue#945
Browse files Browse the repository at this point in the history
  • Loading branch information
Thuyhaile committed Dec 5, 2023
1 parent eaa64d0 commit 5adff3a
Show file tree
Hide file tree
Showing 9 changed files with 327 additions and 123 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ ext.getKeystorePassword = {
}

android {
compileSdkVersion 31
compileSdkVersion 33

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand Down
Binary file added assets/icons/folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 18 additions & 9 deletions lib/blocs/activity_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ class ActivityBloc extends BlocBase {
update();
}

/// Mark the selected activity as Removed when using long press
void removeActivity() {
_activityModel.state = _activityModel.state == ActivityState.Removed
? ActivityState.Normal
: ActivityState.Removed;
update();
}

/// Update the Activity with the new state.
void update() {
_api.activity
Expand Down Expand Up @@ -144,17 +152,18 @@ class ActivityBloc extends BlocBase {
}

/// Method to get alternate name from api
Future<void> getAlternateName() {
Future<Future<AlternateNameModel>> getAlternateName() async {
final Completer<AlternateNameModel> f = Completer<AlternateNameModel>();
_api.alternateName
.get(_user.id!, _activityModel.pictograms.first.id!)
.listen((Object result) {
_alternateName = result as AlternateNameModel?;
f.complete();
}).onError((Object error) {
try {
final AlternateNameModel result = await _api.alternateName
.get(_user.id!, _activityModel.pictograms.first.id!)
.first;
_alternateName = result;
f.complete(result);
} catch (error) {
_alternateName = null;
f.complete();
});
f.completeError(error);
}
return f.future;
}

Expand Down
10 changes: 9 additions & 1 deletion lib/screens/show_activity_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,17 @@ class ShowActivityScreen extends StatelessWidget {
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: GirafAppBar(
leading: IconButton(
icon: const Icon(Icons.arrow_back),
onPressed: () {
_weekplanBloc.loadWeek(_girafUser);
Routes().pop(context);
},
),
title: 'Aktivitet',
appBarIcons: (mode == WeekplanMode.guardian)
? <AppBarIcon, VoidCallback>{AppBarIcon.changeToCitizen: () {}}
: <AppBarIcon, VoidCallback>{AppBarIcon.changeToGuardian: () {}},
key: UniqueKey(),
),
body: childContainer);
}
Expand Down Expand Up @@ -843,6 +849,8 @@ class ShowActivityScreen extends StatelessWidget {
key: const Key('SavePictogramTextForCitizenBtn'),
onPressed: () {
_activityBloc.setAlternateName(tec.text);
_weekplanBloc.loadWeek(_girafUser);
Routes().pop(context);
},
text: 'Gem til borger',
),
Expand Down
5 changes: 3 additions & 2 deletions lib/widgets/giraf_app_bar_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:weekplanner/style/custom_color.dart';
import 'package:weekplanner/widgets/giraf_title_header.dart';

class GirafAppBar extends StatelessWidget implements PreferredSizeWidget {
GirafAppBar({Key? key, this.title, this.appBarIcons})
GirafAppBar({Key? key, this.title, this.appBarIcons, this.leading,})
: toolbarBloc = di.get<ToolbarBloc>(),
preferredSize = const Size.fromHeight(56.0),
super(key: key);
Expand All @@ -19,7 +19,7 @@ class GirafAppBar extends StatelessWidget implements PreferredSizeWidget {

@override
final Size preferredSize;

final Widget? leading; // Define a leading widget
@override
Widget build(BuildContext context) {
toolbarBloc.updateIcons(appBarIcons, context);
Expand All @@ -31,6 +31,7 @@ class GirafAppBar extends StatelessWidget implements PreferredSizeWidget {
title: Text(title ?? '',
overflow: TextOverflow.clip,
style: const TextStyle(color: GirafColors.black)),
leading: leading, // set the leading widget
flexibleSpace: const GirafTitleHeader(),
actions: <Widget>[
StreamBuilder<List<IconButton>>(
Expand Down
18 changes: 18 additions & 0 deletions lib/widgets/weekplan_screen_widgets/activity_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,24 @@ class ActivityCard extends StatelessWidget {
}
}

return const Center(child: CircularProgressIndicator());
case ActivityState.Removed:
if (role == WeekplanMode.guardian) {
return Icon(
Icons.check,
key: const Key('IconComplete'),
color: theme.GirafColors.red,
size: MediaQuery.of(context).size.width,
);
} else if (role == WeekplanMode.citizen) {
if (settings!.completeMark == null) {
return Container(
width: 0,
height: 0,
);
}
}

return const Center(child: CircularProgressIndicator());
case ActivityState.Canceled:
return Icon(
Expand Down
Loading

0 comments on commit 5adff3a

Please sign in to comment.