Skip to content

Commit

Permalink
feat: cancel creation modal (#218)
Browse files Browse the repository at this point in the history
### What does this PR do?
This PR contains a new cancel creation post/article modal screen

### Changes brought by this PR

- When back selected on create article / create post screens we show an
extra confirmation popup that all changes will be reset

### Additional information

<img width="495" alt="Screenshot 2024-10-03 at 14 25 46"
src="https://github.com/user-attachments/assets/aa81afe6-e05f-4aa1-8b54-12dcf17abb83">
<img width="495" alt="Screenshot 2024-10-03 at 14 25 41"
src="https://github.com/user-attachments/assets/b091a2ab-70c2-43d0-ad00-91cb1b0eca4f">
  • Loading branch information
ice-hector authored Oct 7, 2024
1 parent 70226ca commit 10525d0
Show file tree
Hide file tree
Showing 9 changed files with 329 additions and 122 deletions.
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:enableOnBackInvokedCallback="false"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
Expand Down
19 changes: 19 additions & 0 deletions assets/svg/action_createpost_deletepost.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// SPDX-License-Identifier: ice License 1.0

import 'dart:async';

import 'package:back_button_interceptor/back_button_interceptor.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';

class BackHardwareButtonInterceptor extends HookWidget {
const BackHardwareButtonInterceptor({
required this.child,
required this.onBackPress,
super.key,
});
final Widget child;
final Future<void> Function(BuildContext context) onBackPress;

@override
Widget build(BuildContext context) {
final handleBackButton = useCallback(
({
required bool stop,
required RouteInfo info,
required BuildContext context,
}) async {
if (info.ifRouteChanged(context)) {
return false;
} else {
await onBackPress(context);
return true;
}
},
[],
);

final backButtonInterceptor = useCallback(
(bool stop, RouteInfo info) {
return handleBackButton(
stop: stop,
info: info,
context: info.routeWhenAdded?.navigator?.context ?? context,
);
},
[handleBackButton],
);

useEffect(
() {
BackButtonInterceptor.add(backButtonInterceptor, context: context);
return () => BackButtonInterceptor.remove(backButtonInterceptor);
},
[backButtonInterceptor],
);

return child;
}
}
Loading

0 comments on commit 10525d0

Please sign in to comment.