Skip to content

Commit c45d603

Browse files
committed
Reset pointer on app hide, see #280
1 parent 277865b commit c45d603

File tree

7 files changed

+39
-10
lines changed

7 files changed

+39
-10
lines changed

app/lib/cubits/current_index.dart

+4
Original file line numberDiff line numberDiff line change
@@ -428,4 +428,8 @@ class CurrentIndexCubit extends Cubit<CurrentIndex> {
428428
void removeButtons() {
429429
emit(state.copyWith(buttons: null));
430430
}
431+
432+
void resetInput() {
433+
emit(state.copyWith(buttons: null, pointers: []));
434+
}
431435
}

app/lib/dialogs/introduction/start.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import 'package:butterfly/models/document.dart';
66
import 'package:butterfly/models/template.dart';
77
import 'package:flutter/material.dart';
88
import 'package:flutter_bloc/flutter_bloc.dart';
9-
import 'package:go_router/go_router.dart';
109
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
10+
import 'package:go_router/go_router.dart';
1111
import 'package:phosphor_flutter/phosphor_flutter.dart';
1212

1313
import '../../api/format_date_time.dart';
@@ -164,7 +164,6 @@ class _CreateStartViewState extends State<_CreateStartView> {
164164
createdAt: DateTime.now(),
165165
);
166166

167-
bloc.clearHistory();
168167
transformCubit.reset();
169168
currentIndexCubit.reset(document);
170169
bloc.emit(DocumentLoadSuccess(document,
@@ -175,6 +174,7 @@ class _CreateStartViewState extends State<_CreateStartView> {
175174
''),
176175
currentIndexCubit: currentIndexCubit,
177176
settingsCubit: settingsCubit));
177+
bloc.clearHistory();
178178
await bloc.load();
179179
});
180180
},

app/lib/main.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import 'setup.dart' if (dart.library.html) 'setup_web.dart';
2525
import 'theme/manager.dart';
2626
import 'views/main.dart';
2727

28-
const kFileVersion = 6;
28+
const kFileVersion = 5;
2929
Future<void> main([List<String> args = const []]) async {
3030
WidgetsFlutterBinding.ensureInitialized();
3131

app/lib/views/view.dart

+11-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ class MainViewViewport extends StatefulWidget {
2121

2222
enum _MouseState { normal, inverse, scale }
2323

24-
class _MainViewViewportState extends State<MainViewViewport> {
24+
class _MainViewViewportState extends State<MainViewViewport>
25+
with WidgetsBindingObserver {
2526
double size = 1.0;
2627
GlobalKey paintKey = GlobalKey();
2728
_MouseState _mouseState = _MouseState.normal;
@@ -43,6 +44,15 @@ class _MainViewViewportState extends State<MainViewViewport> {
4344
super.dispose();
4445
}
4546

47+
@override
48+
void didChangeAppLifecycleState(AppLifecycleState state) {
49+
if (state == AppLifecycleState.resumed) {
50+
context.read<DocumentBloc>().refresh();
51+
} else {
52+
context.read<CurrentIndexCubit>().resetInput();
53+
}
54+
}
55+
4656
void _handleKey(RawKeyEvent event) {
4757
if (event.data.isShiftPressed) {
4858
_mouseState = _MouseState.inverse;

app/pubspec.lock

+11-4
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ packages:
315315
name: espresso
316316
url: "https://pub.dartlang.org"
317317
source: hosted
318-
version: "0.2.0+3"
318+
version: "0.2.0+4"
319319
fake_async:
320320
dependency: transitive
321321
description:
@@ -357,7 +357,14 @@ packages:
357357
name: flex_color_scheme
358358
url: "https://pub.dartlang.org"
359359
source: hosted
360-
version: "5.1.0"
360+
version: "6.0.0"
361+
flex_seed_scheme:
362+
dependency: transitive
363+
description:
364+
name: flex_seed_scheme
365+
url: "https://pub.dartlang.org"
366+
source: hosted
367+
version: "1.0.0"
361368
flutter:
362369
dependency: "direct main"
363370
description: flutter
@@ -1262,5 +1269,5 @@ packages:
12621269
source: hosted
12631270
version: "0.1.0"
12641271
sdks:
1265-
dart: ">=2.17.0 <3.0.0"
1266-
flutter: ">=3.0.0"
1272+
dart: ">=2.18.0 <3.0.0"
1273+
flutter: ">=3.3.0"

app/pubspec.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ dependencies:
4141
camera: ^0.10.0+1
4242
camera_windows: ^0.2.1+1
4343
window_manager: ^0.2.7
44-
flex_color_scheme: ^5.1.0
44+
flex_color_scheme: ^6.0.0
4545
freezed_annotation: ^2.1.0
4646
json_annotation: ^4.6.0
4747
path: ^1.8.1
@@ -70,7 +70,7 @@ dev_dependencies:
7070
freezed: ^2.1.0+1
7171
build_runner: ^2.2.0
7272
json_serializable: ^6.3.1
73-
espresso: ^0.2.0+3
73+
espresso: ^0.2.0+4
7474

7575
# For information on the generic Dart part of this file, see the
7676
# following page: https://dart.dev/tools/pub/pubspec
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
* Add temporary painter
2+
* Add new painters
3+
* Hand
4+
* Undo
5+
* Redo
6+
* Remove hand, undo, redo buttons from general gui
7+
* Improve UI and UX problems ([#280](https://github.com/LinwoodCloud/Butterfly/issues/280))
8+
* Reset pointer on app hide

0 commit comments

Comments
 (0)