File tree 2 files changed +26
-11
lines changed
android/src/main/kotlin/qiuxiang/android_window
2 files changed +26
-11
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ import kotlin.math.roundToInt
15
15
16
16
class AndroidWindow (
17
17
val service : Service ,
18
- focusable : Boolean ,
18
+ private val focusable : Boolean ,
19
19
width : Int ,
20
20
height : Int ,
21
21
private val x : Int ,
@@ -76,8 +76,10 @@ class AndroidWindow(
76
76
}
77
77
}
78
78
MotionEvent .ACTION_DOWN -> {
79
- layoutParams.flags = layoutParams.flags and WindowManager .LayoutParams .FLAG_NOT_FOCUSABLE .inv ()
80
- windowManager.updateViewLayout(rootView, layoutParams)
79
+ if (focusable) {
80
+ layoutParams.flags = layoutParams.flags and WindowManager .LayoutParams .FLAG_NOT_FOCUSABLE .inv ()
81
+ windowManager.updateViewLayout(rootView, layoutParams)
82
+ }
81
83
}
82
84
}
83
85
false
Original file line number Diff line number Diff line change
1
+ import 'package:flutter/gestures.dart' ;
1
2
import 'package:flutter/material.dart' ;
2
3
3
4
import 'pigeon.g.dart' ;
@@ -54,15 +55,27 @@ class _AndroidWindowState extends State<AndroidWindow> {
54
55
55
56
@override
56
57
Widget build (BuildContext context) {
57
- return GestureDetector (
58
- onPanStart: (event) => start = true ,
59
- onPanUpdate: (event) {
60
- if (start) {
61
- _api.dragStart ();
62
- start = false ;
63
- }
58
+ return RawGestureDetector (
59
+ gestures: {
60
+ PanGestureRecognizer : GestureRecognizerFactoryWithHandlers (
61
+ () => PanGestureRecognizer (),
62
+ (instance) {
63
+ (instance as PanGestureRecognizer )
64
+ ..onStart = (event) {
65
+ start = true ;
66
+ }
67
+ ..onUpdate = (event) {
68
+ if (start) {
69
+ _api.dragStart ();
70
+ start = false ;
71
+ }
72
+ }
73
+ ..onEnd = (event) {
74
+ _api.dragEnd ();
75
+ };
76
+ },
77
+ ),
64
78
},
65
- onPanEnd: (event) => _api.dragEnd (),
66
79
child: widget.child,
67
80
);
68
81
}
You can’t perform that action at this time.
0 commit comments