diff --git a/lib/image/image_page.dart b/lib/image/image_page.dart index 75b4fa5..1f4e3fb 100644 --- a/lib/image/image_page.dart +++ b/lib/image/image_page.dart @@ -9,7 +9,8 @@ import 'package:px_eye/widget/button.dart'; import 'package:window_manager/window_manager.dart'; 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 State createState() => _ImagePageState(); @@ -114,7 +115,7 @@ class _ImagePageState extends State with WindowListener { double dy = 0, Function(double dx, double dy)? moveChanged, }) { - var width = MediaQuery.of(context).size.width - 100; + var width = MediaQuery.of(context).size.width - widget.paddingWidth; if (!show || imageFile == null) { return const SizedBox(); } diff --git a/lib/main.dart b/lib/main.dart index 6903dcc..b3c4f41 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -81,13 +81,15 @@ class _MyHomePageState extends State with WindowListener { double width = 800; double height = 1200; + double paddingWidth = 100; + Future onClickEnter() async { resetScreen(); await Navigator.push( context, PageRouteBuilder( opaque: false, - pageBuilder: (_, __, ___) => const ImagePage(), + pageBuilder: (_, __, ___) => ImagePage(paddingWidth: paddingWidth.toInt()), )); getScreenSize(); } @@ -101,7 +103,6 @@ class _MyHomePageState extends State with WindowListener { @override void onWindowResize() { super.onWindowResize(); - } void getScreenSize() { @@ -172,9 +173,29 @@ class _MyHomePageState extends State with WindowListener { 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: [FilteringTextInputFormatter.digitsOnly], + onChanged: (number) { + paddingWidth = double.tryParse(number) ?? 100; + }, + 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(), + ), + ), ], ), - '(image width will be width - 100)'.toText(size: 10.dp, color: Colors.grey), + '(image width will be width - paddingWidth)'.toText(size: 10.dp, color: Colors.grey), 30.dp.gapColumn, EasyButton( text: 'Enter',