Skip to content

Commit d8363bd

Browse files
committed
Update WindowCaption widget
1 parent da552ed commit d8363bd

File tree

10 files changed

+46
-16
lines changed

10 files changed

+46
-16
lines changed

example/lib/themes/dark_theme.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ import 'package:flutter/material.dart';
22

33
var darkThemeData = ThemeData(
44
brightness: Brightness.dark,
5+
primaryColor: Color(0xff416ff4),
6+
canvasColor: Color(0xff282828),
7+
scaffoldBackgroundColor: Color(0xff1d1d1d),
58
);

example/lib/themes/light_theme.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@ import 'package:flutter/material.dart';
22

33
var lightThemeData = ThemeData(
44
brightness: Brightness.light,
5+
primaryColor: Color(0xff416ff4),
6+
canvasColor: Colors.white,
7+
scaffoldBackgroundColor: Color(0xffF7F9FB),
8+
dividerColor: Colors.grey.withOpacity(0.3),
59
);

example/lib/utils/config.dart

Whitespace-only changes.

images/ic_chrome_close.png

-218 Bytes
Loading

images/ic_chrome_maximize.png

-151 Bytes
Loading

images/ic_chrome_minimize.png

-53 Bytes
Loading

images/ic_chrome_unmaximize.png

366 Bytes
Loading

lib/src/widgets/window_caption.dart

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class WindowCaption extends StatefulWidget {
2626
}
2727

2828
class _WindowCaptionState extends State<WindowCaption> with WindowListener {
29+
bool _isMaximized = false;
30+
2931
@override
3032
void initState() {
3133
windowManager.addListener(this);
@@ -67,7 +69,7 @@ class _WindowCaptionState extends State<WindowCaption> with WindowListener {
6769
color: widget.brightness == Brightness.light
6870
? Colors.black.withOpacity(0.8956)
6971
: Colors.white,
70-
fontSize: 12,
72+
fontSize: 14,
7173
),
7274
child: widget.title ?? Container(),
7375
),
@@ -87,17 +89,20 @@ class _WindowCaptionState extends State<WindowCaption> with WindowListener {
8789
}
8890
},
8991
),
90-
WindowCaptionButton.maximize(
91-
brightness: widget.brightness,
92-
onPressed: () async {
93-
bool isMaximized = await windowManager.isMaximized();
94-
if (isMaximized) {
95-
windowManager.unmaximize();
96-
} else {
92+
if (!_isMaximized)
93+
WindowCaptionButton.maximize(
94+
brightness: widget.brightness,
95+
onPressed: () {
9796
windowManager.maximize();
98-
}
99-
},
100-
),
97+
},
98+
)
99+
else
100+
WindowCaptionButton.unmaximize(
101+
brightness: widget.brightness,
102+
onPressed: () {
103+
windowManager.unmaximize();
104+
},
105+
),
101106
WindowCaptionButton.close(
102107
brightness: widget.brightness,
103108
onPressed: () {
@@ -110,4 +115,16 @@ class _WindowCaptionState extends State<WindowCaption> with WindowListener {
110115
),
111116
);
112117
}
118+
119+
@override
120+
void onWindowMaximize() {
121+
_isMaximized = true;
122+
setState(() {});
123+
}
124+
125+
@override
126+
void onWindowUnmaximize() {
127+
_isMaximized = false;
128+
setState(() {});
129+
}
113130
}

lib/src/widgets/window_caption_button.dart

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ class WindowCaptionButtonIcon extends StatelessWidget {
1717
return Image.asset(
1818
name,
1919
package: package,
20-
width: 16,
20+
width: 15,
2121
color: color,
22+
filterQuality: FilterQuality.high,
2223
);
2324
}
2425
}
@@ -76,6 +77,14 @@ class WindowCaptionButton extends StatefulWidget {
7677
}) : this.iconName = 'images/ic_chrome_maximize.png',
7778
super(key: key);
7879

80+
WindowCaptionButton.unmaximize({
81+
Key? key,
82+
this.brightness,
83+
this.icon,
84+
this.onPressed,
85+
}) : this.iconName = 'images/ic_chrome_unmaximize.png',
86+
super(key: key);
87+
7988
WindowCaptionButton.close({
8089
Key? key,
8190
this.brightness,
@@ -144,10 +153,6 @@ class _WindowCaptionButtonState extends State<WindowCaptionButton> {
144153
bgColor = widget.buttonBgColorScheme.pressed;
145154
iconColor = widget.buttonIconColorScheme.pressed;
146155
}
147-
// if (widget.onPressed == null) {
148-
// bgColor = widget.buttonBgColorScheme.normal;
149-
// iconColor = widget.buttonIconColorScheme.disabled;
150-
// }
151156

152157
return MouseRegion(
153158
onExit: (value) => _onEntered(hovered: false),

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ flutter:
2828
- images/ic_chrome_close.png
2929
- images/ic_chrome_maximize.png
3030
- images/ic_chrome_minimize.png
31+
- images/ic_chrome_unmaximize.png

0 commit comments

Comments
 (0)