Compare commits
9
Commits
dea0bccedf
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70f87c73fc | ||
|
|
ba642e21d0 | ||
|
|
cb4531f046 | ||
|
|
c95c0e192e | ||
|
|
b430697b5c | ||
|
|
90f53a0578 | ||
|
|
595ee6fd6a | ||
|
|
1c53032b3f | ||
|
|
6faf8ed0bb |
No files matched your search
@@ -0,0 +1,4 @@
|
|||||||
|
mixin Consts {
|
||||||
|
static const widthKey = 'window.width';
|
||||||
|
static const heightKey = 'window.height';
|
||||||
|
}
|
||||||
+101
-13
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
class DraggableArea extends StatefulWidget {
|
class DraggableArea extends StatefulWidget {
|
||||||
final Widget child;
|
final Widget child;
|
||||||
@@ -24,23 +25,47 @@ class _DraggableAreaState extends State<DraggableArea> {
|
|||||||
|
|
||||||
double? first;
|
double? first;
|
||||||
double? end;
|
double? end;
|
||||||
|
FocusNode node = FocusNode();
|
||||||
|
|
||||||
|
bool isPressCommand = false;
|
||||||
|
bool isPressShift = false;
|
||||||
|
|
||||||
|
Axis? get axis {
|
||||||
|
if (isPressShift) {
|
||||||
|
return Axis.horizontal;
|
||||||
|
}
|
||||||
|
if (isPressCommand) {
|
||||||
|
return Axis.vertical;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Stack(
|
return Focus(
|
||||||
children: [
|
focusNode: node,
|
||||||
Positioned(
|
autofocus: true,
|
||||||
left: left,
|
onKeyEvent: onKeyInput,
|
||||||
top: top,
|
child: Stack(
|
||||||
child: Draggable(
|
children: [
|
||||||
feedback: widget.child,
|
Positioned(
|
||||||
childWhenDragging: const SizedBox.shrink(),
|
left: left,
|
||||||
onDragUpdate: (u) => onUpdate(u),
|
top: top,
|
||||||
onDragEnd: (detail) => onEnd(detail.offset),
|
child: Draggable(
|
||||||
child: widget.child,
|
axis: axis,
|
||||||
|
feedback: widget.child,
|
||||||
|
childWhenDragging: const SizedBox.shrink(),
|
||||||
|
onDragUpdate: (u) => onUpdate(u),
|
||||||
|
onDragEnd: (detail) => onEnd(detail.offset),
|
||||||
|
onDragStarted: () {
|
||||||
|
first = null;
|
||||||
|
end = null;
|
||||||
|
},
|
||||||
|
child: widget.child,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,10 +75,73 @@ class _DraggableAreaState extends State<DraggableArea> {
|
|||||||
first = null;
|
first = null;
|
||||||
end = null;
|
end = null;
|
||||||
widget.moveChanged?.call(left, top);
|
widget.moveChanged?.call(left, top);
|
||||||
|
node.requestFocus();
|
||||||
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
onUpdate(DragUpdateDetails u) {
|
onUpdate(DragUpdateDetails u) {
|
||||||
|
if (isPressShift) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
first ??= u.globalPosition.dy;
|
first ??= u.globalPosition.dy;
|
||||||
end = u.globalPosition.dy;
|
end = u.globalPosition.dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KeyEventResult onKeyInput(FocusNode nodef, KeyEvent value) {
|
||||||
|
if (value is KeyDownEvent && isCommand(value)) {
|
||||||
|
isPressCommand = true;
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
if (value is KeyUpEvent && isCommand(value)) {
|
||||||
|
isPressCommand = false;
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
if (value is KeyDownEvent && isShift(value)) {
|
||||||
|
isPressShift = true;
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
if (value is KeyUpEvent && isShift(value)) {
|
||||||
|
Future.delayed(const Duration(milliseconds: 500)).then((value) {
|
||||||
|
isPressShift = false;
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() {});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (value is! KeyDownEvent && value is! KeyRepeatEvent) {
|
||||||
|
return KeyEventResult.ignored;
|
||||||
|
}
|
||||||
|
var x = 0;
|
||||||
|
var y = 0;
|
||||||
|
if (value.logicalKey == LogicalKeyboardKey.arrowDown || value.logicalKey == LogicalKeyboardKey.keyJ) {
|
||||||
|
y = 1;
|
||||||
|
} else if (value.logicalKey == LogicalKeyboardKey.arrowUp || value.logicalKey == LogicalKeyboardKey.keyK) {
|
||||||
|
y = -1;
|
||||||
|
} else if (value.logicalKey == LogicalKeyboardKey.arrowRight || value.logicalKey == LogicalKeyboardKey.keyL) {
|
||||||
|
x = 1;
|
||||||
|
} else if (value.logicalKey == LogicalKeyboardKey.arrowLeft || value.logicalKey == LogicalKeyboardKey.keyH) {
|
||||||
|
x = -1;
|
||||||
|
}
|
||||||
|
if (x != 0 || y != 0) {
|
||||||
|
left += x;
|
||||||
|
top += y;
|
||||||
|
widget.moveChanged?.call(left, top);
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
return KeyEventResult.handled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isShift(KeyEvent e) {
|
||||||
|
var key = e.logicalKey;
|
||||||
|
return key == LogicalKeyboardKey.shiftLeft || key == LogicalKeyboardKey.shiftRight || key == LogicalKeyboardKey.shift;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isCommand(KeyEvent e) {
|
||||||
|
var key = e.logicalKey;
|
||||||
|
return key == LogicalKeyboardKey.metaLeft ||
|
||||||
|
key == LogicalKeyboardKey.metaRight ||
|
||||||
|
key == LogicalKeyboardKey.meta ||
|
||||||
|
key == LogicalKeyboardKey.controlLeft ||
|
||||||
|
key == LogicalKeyboardKey.controlRight ||
|
||||||
|
key == LogicalKeyboardKey.control;
|
||||||
}
|
}
|
||||||
+30
-26
@@ -9,15 +9,16 @@ import 'package:px_eye/widget/button.dart';
|
|||||||
import 'package:window_manager/window_manager.dart';
|
import 'package:window_manager/window_manager.dart';
|
||||||
|
|
||||||
class ImagePage extends StatefulWidget {
|
class ImagePage extends StatefulWidget {
|
||||||
const ImagePage({Key? key}) : super(key: key);
|
const ImagePage({Key? key, this.paddingWidth = 100}) : super(key: key);
|
||||||
|
final int paddingWidth;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ImagePage> createState() => _ImagePageState();
|
State<ImagePage> createState() => _ImagePageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ImagePageState extends State<ImagePage> with WindowListener {
|
class _ImagePageState extends State<ImagePage> with WindowListener {
|
||||||
File? image;
|
static File? image;
|
||||||
File? image2;
|
static File? image2;
|
||||||
bool isImageSelected1 = true;
|
bool isImageSelected1 = true;
|
||||||
bool isImageSelected2 = true;
|
bool isImageSelected2 = true;
|
||||||
double opacity1 = 1;
|
double opacity1 = 1;
|
||||||
@@ -38,7 +39,6 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
width: 50.dp,
|
width: 50.dp,
|
||||||
child: EasyButton(
|
child: EasyButton(
|
||||||
color: Colors.blue,
|
|
||||||
text: 'reset',
|
text: 'reset',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
offsetDx1 = 0;
|
offsetDx1 = 0;
|
||||||
@@ -59,13 +59,15 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
|||||||
child: 'Window Opacity'.toText(size: 12.dp),
|
child: 'Window Opacity'.toText(size: 12.dp),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Slider(
|
child: ExcludeFocus(
|
||||||
value: opacityWindow,
|
child: Slider(
|
||||||
onChanged: (v) {
|
value: opacityWindow,
|
||||||
opacityWindow = v;
|
onChanged: (v) {
|
||||||
windowManager.setOpacity(opacityWindow);
|
opacityWindow = v;
|
||||||
setState(() {});
|
windowManager.setOpacity(opacityWindow);
|
||||||
},
|
setState(() {});
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -83,7 +85,6 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
|||||||
moveChanged: (dx, dy) {
|
moveChanged: (dx, dy) {
|
||||||
offsetDx1 = dx;
|
offsetDx1 = dx;
|
||||||
offsetDy1 = dy;
|
offsetDy1 = dy;
|
||||||
setState(() {});
|
|
||||||
},
|
},
|
||||||
dx: offsetDx1,
|
dx: offsetDx1,
|
||||||
dy: offsetDy1,
|
dy: offsetDy1,
|
||||||
@@ -96,7 +97,6 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
|||||||
moveChanged: (dx, dy) {
|
moveChanged: (dx, dy) {
|
||||||
offsetDx2 = dx;
|
offsetDx2 = dx;
|
||||||
offsetDy2 = dy;
|
offsetDy2 = dy;
|
||||||
setState(() {});
|
|
||||||
},
|
},
|
||||||
dx: offsetDx2,
|
dx: offsetDx2,
|
||||||
dy: offsetDy2,
|
dy: offsetDy2,
|
||||||
@@ -117,10 +117,10 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
|||||||
double dy = 0,
|
double dy = 0,
|
||||||
Function(double dx, double dy)? moveChanged,
|
Function(double dx, double dy)? moveChanged,
|
||||||
}) {
|
}) {
|
||||||
|
var width = MediaQuery.of(context).size.width - widget.paddingWidth;
|
||||||
if (!show || imageFile == null) {
|
if (!show || imageFile == null) {
|
||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
}
|
}
|
||||||
var width = MediaQuery.of(context).size.width - 100;
|
|
||||||
return DraggableArea(
|
return DraggableArea(
|
||||||
key: ValueKey('${DateTime.now()}'),
|
key: ValueKey('${DateTime.now()}'),
|
||||||
dx: dx,
|
dx: dx,
|
||||||
@@ -177,12 +177,14 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
|||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 80.dp,
|
width: 80.dp,
|
||||||
child: Slider(
|
child: ExcludeFocus(
|
||||||
value: opacity1,
|
child: Slider(
|
||||||
onChanged: (v) {
|
value: opacity1,
|
||||||
opacity1 = v;
|
onChanged: (v) {
|
||||||
setState(() {});
|
opacity1 = v;
|
||||||
},
|
setState(() {});
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
@@ -203,12 +205,14 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
|||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 80.dp,
|
width: 80.dp,
|
||||||
child: Slider(
|
child: ExcludeFocus(
|
||||||
value: opacity2,
|
child: Slider(
|
||||||
onChanged: (v) {
|
value: opacity2,
|
||||||
opacity2 = v;
|
onChanged: (v) {
|
||||||
setState(() {});
|
opacity2 = v;
|
||||||
},
|
setState(() {});
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
import 'package:px_eye/const/const.dart';
|
||||||
|
import 'package:px_eye/extension/extension.dart';
|
||||||
|
import 'package:px_eye/sp/sp.dart';
|
||||||
|
import 'package:window_manager/window_manager.dart';
|
||||||
|
|
||||||
|
class WindowListenerImp extends WindowListener {
|
||||||
|
@override
|
||||||
|
void onWindowResized() {
|
||||||
|
super.onWindowResized();
|
||||||
|
saveWindowSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void saveWindowSize() async {
|
||||||
|
var size = await windowManager.getSize();
|
||||||
|
screenSize = size;
|
||||||
|
SP.setDouble(Consts.widthKey, size.width);
|
||||||
|
SP.setDouble(Consts.heightKey, size.height);
|
||||||
|
}
|
||||||
|
}
|
||||||
+82
-16
@@ -1,7 +1,10 @@
|
|||||||
import 'package:bot_toast/bot_toast.dart';
|
import 'package:bot_toast/bot_toast.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:px_eye/const/const.dart';
|
||||||
import 'package:px_eye/image/image_page.dart';
|
import 'package:px_eye/image/image_page.dart';
|
||||||
|
import 'package:px_eye/interface/window_interface.dart';
|
||||||
|
import 'package:px_eye/sp/sp.dart';
|
||||||
import 'package:px_eye/widget/button.dart';
|
import 'package:px_eye/widget/button.dart';
|
||||||
import 'package:window_manager/window_manager.dart';
|
import 'package:window_manager/window_manager.dart';
|
||||||
|
|
||||||
@@ -9,20 +12,31 @@ import 'extension/extension.dart';
|
|||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
await SP.init();
|
||||||
|
var width = SP.getDouble(Consts.widthKey, 800);
|
||||||
|
var height = SP.getDouble(Consts.heightKey, 1200);
|
||||||
|
|
||||||
// Must add this line.
|
// Must add this line.
|
||||||
await windowManager.ensureInitialized();
|
await windowManager.ensureInitialized();
|
||||||
|
|
||||||
WindowOptions windowOptions = const WindowOptions(
|
WindowOptions windowOptions = WindowOptions(
|
||||||
size: Size(800, 1600),
|
size: Size(width, height),
|
||||||
);
|
);
|
||||||
|
|
||||||
windowManager.waitUntilReadyToShow(windowOptions, () async {
|
windowManager.waitUntilReadyToShow(windowOptions, () async {
|
||||||
await windowManager.show();
|
await windowManager.show();
|
||||||
await windowManager.focus();
|
await windowManager.focus();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
windowManager.addListener(WindowListenerImp());
|
||||||
|
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var primaryColor = Colors.green;
|
||||||
|
var secondaryColor = Colors.green;
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
const MyApp({super.key});
|
const MyApp({super.key});
|
||||||
|
|
||||||
@@ -34,8 +48,16 @@ class MyApp extends StatelessWidget {
|
|||||||
builder: BotToastInit(),
|
builder: BotToastInit(),
|
||||||
title: 'Pixel eye',
|
title: 'Pixel eye',
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
primaryColor: Colors.transparent,
|
primaryColor: primaryColor,
|
||||||
|
colorScheme: ColorScheme.light(
|
||||||
|
secondary: secondaryColor,
|
||||||
|
primary: primaryColor,
|
||||||
|
),
|
||||||
|
appBarTheme: AppBarTheme(
|
||||||
|
backgroundColor: primaryColor,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
navigatorObservers: [BotToastNavigatorObserver()],
|
navigatorObservers: [BotToastNavigatorObserver()],
|
||||||
//2. registered route observer
|
//2. registered route observer
|
||||||
home: Builder(builder: (context) {
|
home: Builder(builder: (context) {
|
||||||
@@ -55,29 +77,51 @@ class MyHomePage extends StatefulWidget {
|
|||||||
State<MyHomePage> createState() => _MyHomePageState();
|
State<MyHomePage> createState() => _MyHomePageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
class _MyHomePageState extends State<MyHomePage> with WindowListener {
|
||||||
int width = 800;
|
double width = 800;
|
||||||
int height = 1600;
|
double height = 1200;
|
||||||
|
|
||||||
|
double paddingWidth = 100;
|
||||||
|
|
||||||
Future<void> onClickEnter() async {
|
Future<void> onClickEnter() async {
|
||||||
resetScreen();
|
resetScreen();
|
||||||
Navigator.push(
|
await Navigator.push(
|
||||||
context,
|
context,
|
||||||
PageRouteBuilder<void>(
|
PageRouteBuilder<void>(
|
||||||
opaque: false,
|
opaque: false,
|
||||||
pageBuilder: (_, __, ___) => const ImagePage(),
|
pageBuilder: (_, __, ___) => ImagePage(paddingWidth: paddingWidth.toInt()),
|
||||||
));
|
));
|
||||||
|
getScreenSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
initState() {
|
||||||
|
super.initState();
|
||||||
|
getScreenSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onWindowResize() {
|
||||||
|
super.onWindowResize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void getScreenSize() {
|
||||||
|
width = SP.getDouble(Consts.widthKey, 800);
|
||||||
|
height = SP.getDouble(Consts.heightKey, 1200);
|
||||||
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> resetScreen() async {
|
Future<void> resetScreen() async {
|
||||||
var size = Size(width.toDouble(), height.toDouble());
|
var size = Size(width, height);
|
||||||
Offset newPosition = await calcWindowPosition(size, Alignment.center);
|
await windowManager.setBounds(null, position: null, size: size, animate: true);
|
||||||
await windowManager.setBounds(null, position: newPosition, size: size, animate: true);
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
var size = MediaQuery.of(context).size;
|
||||||
|
width = size.width;
|
||||||
|
height = size.height;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(widget.title),
|
title: Text(widget.title),
|
||||||
@@ -87,6 +131,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
padding: EdgeInsets.all(8.dp),
|
padding: EdgeInsets.all(8.dp),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
@@ -95,11 +140,11 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
height: 20.dp,
|
height: 20.dp,
|
||||||
width: 50.dp,
|
width: 50.dp,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: TextEditingController(text: '$width'),
|
controller: TextEditingController(text: '${width.toInt()}'),
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
inputFormatters: <TextInputFormatter>[FilteringTextInputFormatter.digitsOnly],
|
inputFormatters: <TextInputFormatter>[FilteringTextInputFormatter.digitsOnly],
|
||||||
onChanged: (number) {
|
onChanged: (number) {
|
||||||
width = int.tryParse(number) ?? 800;
|
width = double.tryParse(number) ?? 800;
|
||||||
},
|
},
|
||||||
style: TextStyle(fontSize: 14.dp, fontWeight: FontWeight.w600),
|
style: TextStyle(fontSize: 14.dp, fontWeight: FontWeight.w600),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
@@ -114,11 +159,31 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
height: 20.dp,
|
height: 20.dp,
|
||||||
width: 50.dp,
|
width: 50.dp,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: TextEditingController(text: '$height'),
|
controller: TextEditingController(text: '${height.toInt()}'),
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
inputFormatters: <TextInputFormatter>[FilteringTextInputFormatter.digitsOnly],
|
inputFormatters: <TextInputFormatter>[FilteringTextInputFormatter.digitsOnly],
|
||||||
onChanged: (number) {
|
onChanged: (number) {
|
||||||
height = int.tryParse(number) ?? 800;
|
height = double.tryParse(number) ?? 800;
|
||||||
|
},
|
||||||
|
style: TextStyle(fontSize: 14.dp, fontWeight: FontWeight.w600),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
contentPadding: EdgeInsets.all(2.dp),
|
||||||
|
hintStyle: TextStyle(fontSize: 14.dp, color: Colors.grey, fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
|
onSubmitted: (_) => onClickEnter(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
20.gapRow,
|
||||||
|
'paddingWidth:'.toText(size: 9.dp),
|
||||||
|
SizedBox(
|
||||||
|
height: 20.dp,
|
||||||
|
width: 50.dp,
|
||||||
|
child: TextField(
|
||||||
|
controller: TextEditingController(text: '${paddingWidth.toInt()}'),
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
inputFormatters: <TextInputFormatter>[FilteringTextInputFormatter.digitsOnly],
|
||||||
|
onChanged: (number) {
|
||||||
|
paddingWidth = double.tryParse(number) ?? 100;
|
||||||
},
|
},
|
||||||
style: TextStyle(fontSize: 14.dp, fontWeight: FontWeight.w600),
|
style: TextStyle(fontSize: 14.dp, fontWeight: FontWeight.w600),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
@@ -130,7 +195,8 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
5.dp.gapColumn,
|
'(image width will be width - paddingWidth)'.toText(size: 10.dp, color: Colors.grey),
|
||||||
|
30.dp.gapColumn,
|
||||||
EasyButton(
|
EasyButton(
|
||||||
text: 'Enter',
|
text: 'Enter',
|
||||||
onPressed: () => onClickEnter(),
|
onPressed: () => onClickEnter(),
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
class SP {
|
||||||
|
static late SharedPreferences prefs;
|
||||||
|
|
||||||
|
static Future<void> init() async {
|
||||||
|
prefs = await SharedPreferences.getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
static double getDouble(String key, [double def = 0]) {
|
||||||
|
return prefs.getDouble(key) ?? def;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<bool> setDouble(String key, double value) {
|
||||||
|
return prefs.setDouble(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static String? getString(String key) {
|
||||||
|
return prefs.getString(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<bool> setString(String key, String value) {
|
||||||
|
return prefs.setString(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -41,13 +41,13 @@ class EasyButton extends StatelessWidget {
|
|||||||
if (states.contains(MaterialState.disabled)) {
|
if (states.contains(MaterialState.disabled)) {
|
||||||
return Colors.grey.withOpacity(0.5);
|
return Colors.grey.withOpacity(0.5);
|
||||||
}
|
}
|
||||||
return color ?? (type == ButtonType.secondary ? Colors.white : Colors.blue);
|
return color ?? (type == ButtonType.secondary ? Colors.white : Theme.of(context).primaryColor);
|
||||||
}),
|
}),
|
||||||
foregroundColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) {
|
foregroundColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) {
|
||||||
if (states.contains(MaterialState.disabled)) {
|
if (states.contains(MaterialState.disabled)) {
|
||||||
return Colors.grey.withOpacity(0.1);
|
return Colors.grey.withOpacity(0.1);
|
||||||
}
|
}
|
||||||
return color ?? (type == ButtonType.secondary ? Colors.white : Colors.blue);
|
return color ?? (type == ButtonType.secondary ? Colors.white : Theme.of(context).primaryColor);
|
||||||
}),
|
}),
|
||||||
minimumSize: MaterialStateProperty.all(Size(minWidth, height)),
|
minimumSize: MaterialStateProperty.all(Size(minWidth, height)),
|
||||||
shape: MaterialStateProperty.all(
|
shape: MaterialStateProperty.all(
|
||||||
|
|||||||
@@ -6,9 +6,11 @@ import FlutterMacOS
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
import screen_retriever
|
import screen_retriever
|
||||||
|
import shared_preferences_foundation
|
||||||
import window_manager
|
import window_manager
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
|
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
|
||||||
|
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||||
WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
|
WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
|
||||||
}
|
}
|
||||||
@@ -2,12 +2,16 @@ PODS:
|
|||||||
- FlutterMacOS (1.0.0)
|
- FlutterMacOS (1.0.0)
|
||||||
- screen_retriever (0.0.1):
|
- screen_retriever (0.0.1):
|
||||||
- FlutterMacOS
|
- FlutterMacOS
|
||||||
|
- shared_preferences_foundation (0.0.1):
|
||||||
|
- Flutter
|
||||||
|
- FlutterMacOS
|
||||||
- window_manager (0.2.0):
|
- window_manager (0.2.0):
|
||||||
- FlutterMacOS
|
- FlutterMacOS
|
||||||
|
|
||||||
DEPENDENCIES:
|
DEPENDENCIES:
|
||||||
- FlutterMacOS (from `Flutter/ephemeral`)
|
- FlutterMacOS (from `Flutter/ephemeral`)
|
||||||
- screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`)
|
- screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`)
|
||||||
|
- shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/macos`)
|
||||||
- window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`)
|
- window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`)
|
||||||
|
|
||||||
EXTERNAL SOURCES:
|
EXTERNAL SOURCES:
|
||||||
@@ -15,12 +19,15 @@ EXTERNAL SOURCES:
|
|||||||
:path: Flutter/ephemeral
|
:path: Flutter/ephemeral
|
||||||
screen_retriever:
|
screen_retriever:
|
||||||
:path: Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos
|
:path: Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos
|
||||||
|
shared_preferences_foundation:
|
||||||
|
:path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/macos
|
||||||
window_manager:
|
window_manager:
|
||||||
:path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos
|
:path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos
|
||||||
|
|
||||||
SPEC CHECKSUMS:
|
SPEC CHECKSUMS:
|
||||||
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
|
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
|
||||||
screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38
|
screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38
|
||||||
|
shared_preferences_foundation: 986fc17f3d3251412d18b0265f9c64113a8c2472
|
||||||
window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8
|
window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8
|
||||||
|
|
||||||
PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7
|
PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7
|
||||||
|
|||||||
+112
@@ -73,6 +73,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.1"
|
version: "2.0.1"
|
||||||
|
file:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: file
|
||||||
|
sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.1.4"
|
||||||
file_picker:
|
file_picker:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -160,6 +168,38 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.2"
|
version: "1.8.2"
|
||||||
|
path_provider_linux:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: path_provider_linux
|
||||||
|
sha256: "2ae08f2216225427e64ad224a24354221c2c7907e448e6e0e8b57b1eb9f10ad1"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.10"
|
||||||
|
path_provider_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: path_provider_platform_interface
|
||||||
|
sha256: "57585299a729335f1298b43245842678cb9f43a6310351b18fb577d6e33165ec"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.6"
|
||||||
|
path_provider_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: path_provider_windows
|
||||||
|
sha256: f53720498d5a543f9607db4b0e997c4b5438884de25b0f73098cc2671a51b130
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.5"
|
||||||
|
platform:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: platform
|
||||||
|
sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.1.0"
|
||||||
plugin_platform_interface:
|
plugin_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -168,6 +208,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.4"
|
version: "2.1.4"
|
||||||
|
process:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: process
|
||||||
|
sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "4.2.4"
|
||||||
screen_retriever:
|
screen_retriever:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -176,6 +224,62 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.6"
|
version: "0.1.6"
|
||||||
|
shared_preferences:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: shared_preferences
|
||||||
|
sha256: "858aaa72d8f61637d64e776aca82e1c67e6d9ee07979123c5d17115031c1b13b"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.0"
|
||||||
|
shared_preferences_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_android
|
||||||
|
sha256: "8304d8a1f7d21a429f91dee552792249362b68a331ac5c3c1caf370f658873f6"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.0"
|
||||||
|
shared_preferences_foundation:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_foundation
|
||||||
|
sha256: "0c1c16c56c9708aa9c361541a6f0e5cc6fc12a3232d866a687a7b7db30032b07"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.2.1"
|
||||||
|
shared_preferences_linux:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_linux
|
||||||
|
sha256: "9d387433ca65717bbf1be88f4d5bb18f10508917a8fa2fb02e0fd0d7479a9afa"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.2.0"
|
||||||
|
shared_preferences_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_platform_interface
|
||||||
|
sha256: fb5cf25c0235df2d0640ac1b1174f6466bd311f621574997ac59018a6664548d
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.2.0"
|
||||||
|
shared_preferences_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_web
|
||||||
|
sha256: "74083203a8eae241e0de4a0d597dbedab3b8fef5563f33cf3c12d7e93c655ca5"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.0"
|
||||||
|
shared_preferences_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_windows
|
||||||
|
sha256: "5e588e2efef56916a3b229c3bfe81e6a525665a454519ca51dbcc4236a274173"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.2.0"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -253,6 +357,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.3.2"
|
version: "0.3.2"
|
||||||
|
xdg_directories:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: xdg_directories
|
||||||
|
sha256: ee1505df1426458f7f60aac270645098d318a8b4766d85fde75f76f2e21807d1
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.0"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.19.4 <3.0.0"
|
dart: ">=2.19.4 <3.0.0"
|
||||||
flutter: ">=3.0.0"
|
flutter: ">=3.0.0"
|
||||||
@@ -38,6 +38,7 @@ dependencies:
|
|||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
cupertino_icons: ^1.0.2
|
cupertino_icons: ^1.0.2
|
||||||
|
shared_preferences: ^2.1.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
Reference in new issue
Block a user