support primary color

This commit is contained in:
Siyi Guo committed 2023-04-13 16:43:48 +08:00
1 parent 595ee6fd6a
commit 90f53a0578
3 files changed
+39 -15

No files matched your search

-1
View File
@@ -38,7 +38,6 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
SizedBox(
width: 50.dp,
child: EasyButton(
color: Colors.blue,
text: 'reset',
onPressed: () {
offsetDx1 = 0;
+37 -12
View File
@@ -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<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int width = 800;
int height = 1200;
class _MyHomePageState extends State<MyHomePage> with WindowListener {
double width = 800;
double height = 1200;
Future<void> onClickEnter() async {
resetScreen();
Navigator.push(
await Navigator.push(
context,
PageRouteBuilder<void>(
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<void> 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<MyHomePage> {
height: 20.dp,
width: 50.dp,
child: TextField(
controller: TextEditingController(text: '$width'),
controller: TextEditingController(text: '${width.toInt()}'),
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[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<MyHomePage> {
height: 20.dp,
width: 50.dp,
child: TextField(
controller: TextEditingController(text: '$height'),
controller: TextEditingController(text: '${height.toInt()}'),
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[FilteringTextInputFormatter.digitsOnly],
onChanged: (number) {
height = int.tryParse(number) ?? 800;
height = double.tryParse(number) ?? 800;
},
style: TextStyle(fontSize: 14.dp, fontWeight: FontWeight.w600),
decoration: InputDecoration(
+2 -2
View File
@@ -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<Color>((Set<MaterialState> 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(