diff --git a/lib/image/image_page.dart b/lib/image/image_page.dart index b7879ef..75b4fa5 100644 --- a/lib/image/image_page.dart +++ b/lib/image/image_page.dart @@ -38,7 +38,6 @@ class _ImagePageState extends State with WindowListener { SizedBox( width: 50.dp, child: EasyButton( - color: Colors.blue, text: 'reset', onPressed: () { offsetDx1 = 0; diff --git a/lib/main.dart b/lib/main.dart index 6071d39..6903dcc 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -34,6 +34,9 @@ void main() async { runApp(const MyApp()); } +var primaryColor = Colors.green; +var secondaryColor = Colors.green; + class MyApp extends StatelessWidget { const MyApp({super.key}); @@ -45,8 +48,16 @@ class MyApp extends StatelessWidget { builder: BotToastInit(), title: 'Pixel eye', theme: ThemeData( - primaryColor: Colors.transparent, + primaryColor: primaryColor, + colorScheme: ColorScheme.light( + secondary: secondaryColor, + primary: primaryColor, + ), + appBarTheme: AppBarTheme( + backgroundColor: primaryColor, + ), ), + navigatorObservers: [BotToastNavigatorObserver()], //2. registered route observer home: Builder(builder: (context) { @@ -66,36 +77,50 @@ class MyHomePage extends StatefulWidget { State createState() => _MyHomePageState(); } -class _MyHomePageState extends State { - int width = 800; - int height = 1200; +class _MyHomePageState extends State with WindowListener { + double width = 800; + double height = 1200; Future onClickEnter() async { resetScreen(); - Navigator.push( + await Navigator.push( context, PageRouteBuilder( opaque: false, pageBuilder: (_, __, ___) => const ImagePage(), )); + getScreenSize(); } @override initState() { super.initState(); - width = SP.getDouble(Consts.widthKey, 800).toInt(); - height = SP.getDouble(Consts.heightKey, 1200).toInt(); + getScreenSize(); + } + + @override + void onWindowResize() { + super.onWindowResize(); + + } + + void getScreenSize() { + width = SP.getDouble(Consts.widthKey, 800); + height = SP.getDouble(Consts.heightKey, 1200); setState(() {}); } Future resetScreen() async { - var size = Size(width.toDouble(), height.toDouble()); + var size = Size(width, height); await windowManager.setBounds(null, position: null, size: size, animate: true); setState(() {}); } @override Widget build(BuildContext context) { + var size = MediaQuery.of(context).size; + width = size.width; + height = size.height; return Scaffold( appBar: AppBar( title: Text(widget.title), @@ -114,11 +139,11 @@ class _MyHomePageState extends State { height: 20.dp, width: 50.dp, child: TextField( - controller: TextEditingController(text: '$width'), + controller: TextEditingController(text: '${width.toInt()}'), keyboardType: TextInputType.number, inputFormatters: [FilteringTextInputFormatter.digitsOnly], onChanged: (number) { - width = int.tryParse(number) ?? 800; + width = double.tryParse(number) ?? 800; }, style: TextStyle(fontSize: 14.dp, fontWeight: FontWeight.w600), decoration: InputDecoration( @@ -133,11 +158,11 @@ class _MyHomePageState extends State { height: 20.dp, width: 50.dp, child: TextField( - controller: TextEditingController(text: '$height'), + controller: TextEditingController(text: '${height.toInt()}'), keyboardType: TextInputType.number, inputFormatters: [FilteringTextInputFormatter.digitsOnly], onChanged: (number) { - height = int.tryParse(number) ?? 800; + height = double.tryParse(number) ?? 800; }, style: TextStyle(fontSize: 14.dp, fontWeight: FontWeight.w600), decoration: InputDecoration( diff --git a/lib/widget/button.dart b/lib/widget/button.dart index b79d078..3f7ae83 100644 --- a/lib/widget/button.dart +++ b/lib/widget/button.dart @@ -41,13 +41,13 @@ class EasyButton extends StatelessWidget { if (states.contains(MaterialState.disabled)) { 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((Set states) { if (states.contains(MaterialState.disabled)) { 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)), shape: MaterialStateProperty.all(