-
Notifications
You must be signed in to change notification settings - Fork 54
/
main.dart
890 lines (864 loc) · 37.7 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
import 'dart:async';
import 'dart:io';
import 'dart:math';
import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:flutter/material.dart';
import 'package:flutter_acrylic/flutter_acrylic.dart';
import 'package:flutter_acrylic/widgets/visual_effect_subview_container/visual_effect_subview_container.dart';
import 'package:flutter_acrylic_example/widgets/macos_action_menu/macos_action_menu.dart';
import 'package:flutter_acrylic_example/widgets/sidebar_frame/sidebar_frame.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Window.initialize();
if (Platform.isWindows) {
await Window.hideWindowControls();
}
runApp(MyApp());
if (Platform.isWindows) {
doWhenWindowReady(() {
appWindow
..minSize = Size(640, 360)
..size = Size(720, 540)
..alignment = Alignment.center
..show();
});
}
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
splashFactory: InkRipple.splashFactory,
),
darkTheme: ThemeData.dark().copyWith(
splashFactory: InkRipple.splashFactory,
),
themeMode: ThemeMode.dark,
home: MyAppBody(),
);
}
}
enum InterfaceBrightness {
light,
dark,
auto,
}
extension InterfaceBrightnessExtension on InterfaceBrightness {
bool getIsDark(BuildContext? context) {
if (this == InterfaceBrightness.light) return false;
if (this == InterfaceBrightness.auto) {
if (context == null) return true;
return MediaQuery.of(context).platformBrightness == Brightness.dark;
}
return true;
}
Color getForegroundColor(BuildContext? context) {
return getIsDark(context) ? Colors.white : Colors.black;
}
}
class MyAppBody extends StatefulWidget {
MyAppBody({Key? key}) : super(key: key);
@override
MyAppBodyState createState() => MyAppBodyState();
}
class MyAppBodyState extends State<MyAppBody> {
WindowEffect effect = WindowEffect.transparent;
Color color = Platform.isWindows ? Color(0xCC222222) : Colors.transparent;
InterfaceBrightness brightness =
Platform.isMacOS ? InterfaceBrightness.auto : InterfaceBrightness.dark;
MacOSBlurViewState macOSBlurViewState =
MacOSBlurViewState.followsWindowActiveState;
@override
void initState() {
super.initState();
this.setWindowEffect(this.effect);
}
void setWindowEffect(WindowEffect? value) {
Window.setEffect(
effect: value!,
color: this.color,
dark: brightness == InterfaceBrightness.dark,
);
if (Platform.isMacOS) {
if (brightness != InterfaceBrightness.auto) {
Window.overrideMacOSBrightness(
dark: brightness == InterfaceBrightness.dark,
);
}
}
this.setState(() => this.effect = value);
}
void setBrightness(InterfaceBrightness brightness) {
this.brightness = brightness;
if (this.brightness == InterfaceBrightness.dark) {
color = Platform.isWindows ? Color(0xCC222222) : Colors.transparent;
} else {
color = Platform.isWindows ? Color(0x22DDDDDD) : Colors.transparent;
}
this.setWindowEffect(this.effect);
}
/// Lets the madness begin! (macOS only.)
///
/// This method plays a silly little effect that is achieved using visual
/// effect subviews. It is designed to showcase a low-level approach to using
/// visual effect subviews without relying on the
/// [VisualEffectSubviewContainer] widget.
///
/// In most cases, using the container widget is preferable, though, due to
/// its ease of use.
void letTheMadnessBegin() async {
final random = Random();
final windowWidth = MediaQuery.of(context).size.width;
final windowHeight = MediaQuery.of(context).size.height;
for (var i = 0; i < 10; i += 1) {
// Create some random visual effect view.
final size = random.nextDouble() * 64.0 + 32.0;
final speed = random.nextDouble() * 2.0 + 2.0;
var frameX = -size - random.nextDouble() * 32.0;
final frameY = random.nextDouble() * windowHeight;
// Remember to store its ID.
final subviewId =
await Window.addVisualEffectSubview(VisualEffectSubviewProperties(
effect: WindowEffect.hudWindow,
alphaValue: random.nextDouble(),
cornerRadius: random.nextDouble() * 48.0,
cornerMask: random.nextInt(16),
frameX: frameX,
frameY: frameY,
frameWidth: size,
frameHeight: size,
));
Timer.periodic(const Duration(milliseconds: 8), (timer) {
// Now, let's periodically update its position:
frameX += speed;
Window.updateVisualEffectSubviewProperties(
subviewId,
VisualEffectSubviewProperties(
frameX: frameX,
frameY: frameY + sin(frameX * 0.01) * 32.0,
),
);
if (frameX > windowWidth) {
// Remember to remove the visual effect subview when you no longer
// need it.
Window.removeVisualEffectSubview(subviewId);
timer.cancel();
}
});
}
}
@override
Widget build(BuildContext context) {
// The [TitlebarSafeArea] widget is required when running on macOS and
// enabling the full-size content view using
// [Window.setFullSizeContentView]. It ensures that its child is not covered
// by the macOS title bar.
return TitlebarSafeArea(
child: SidebarFrame(
macOSBlurViewState: macOSBlurViewState,
sidebar: SizedBox.expand(
child: Scaffold(
backgroundColor: Colors.transparent,
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0),
child: Text(
'Sidebar',
style: TextStyle(
color: brightness.getForegroundColor(context),
fontWeight: FontWeight.bold,
),
),
),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 8.0,
horizontal: 12.0,
),
child: Text(
'This is an example of a sidebar that has been '
'implemented using the TransparentMacOSSidebar widget.',
style: TextStyle(
color: brightness.getForegroundColor(context),
),
),
),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 4.0,
horizontal: 12.0,
),
child: Text(
'Check out the sidebar_frame.dart file to see how it '
'has been implemented!',
style: TextStyle(
color: brightness.getForegroundColor(context),
),
),
),
const SizedBox(height: 16.0),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 4.0,
horizontal: 12.0,
),
child: Text(
'Press the following button if you would like to see '
'some visual effect subview madness:',
style: TextStyle(
color: brightness.getForegroundColor(context),
),
),
),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 12.0,
horizontal: 12.0,
),
child: Center(
child: ElevatedButton(
onPressed: letTheMadnessBegin,
child: Text('Let the madness begin!'),
),
),
),
],
),
),
),
),
child: Stack(
children: [
Scaffold(
backgroundColor: Colors.transparent,
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
WindowTitleBar(
brightness: brightness,
),
Padding(
padding: EdgeInsets.only(
left: 20.0,
bottom: 20.0,
top: 12.0,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Flutter Acrylic',
style: TextStyle(
fontSize: 32.0,
color: brightness.getForegroundColor(context),
),
),
SizedBox(height: 4.0),
Text(
'github.com/alexmercerind/flutter_acrylic',
style: TextStyle(
color: brightness.getForegroundColor(context),
),
),
],
),
),
Expanded(
child: buildEffectMenu(context),
),
Divider(
height: 1.0,
color: brightness == InterfaceBrightness.dark
? Colors.white12
: Colors.black12,
),
buildActionButtonBar(context),
buildMacOSActionMenuOpener(context),
],
),
),
],
),
),
);
}
ButtonBar buildActionButtonBar(BuildContext context) {
return ButtonBar(
alignment: MainAxisAlignment.start,
overflowButtonSpacing: 4.0,
children: [
ElevatedButton(
onPressed: () => setState(() {
setBrightness(
brightness == InterfaceBrightness.dark
? InterfaceBrightness.light
: InterfaceBrightness.dark,
);
}),
child: Text(
'Dark: ${(() {
switch (brightness) {
case InterfaceBrightness.light:
return 'light';
case InterfaceBrightness.dark:
return 'dark';
default:
return 'auto';
}
})()}',
style: TextStyle(
color: Colors.white,
),
),
),
ElevatedButton(
onPressed: Window.hideWindowControls,
child: Text(
'Hide controls',
style: TextStyle(
color: Colors.white,
),
),
),
ElevatedButton(
onPressed: Window.showWindowControls,
child: Text(
'Show controls',
style: TextStyle(
color: Colors.white,
),
),
),
ElevatedButton(
onPressed: Window.enterFullscreen,
child: Text(
'Enter fullscreen',
style: TextStyle(
color: Colors.white,
),
),
),
ElevatedButton(
onPressed: Window.exitFullscreen,
child: Text(
'Exit fullscreen',
style: TextStyle(
color: Colors.white,
),
),
),
],
);
}
Widget buildMacOSActionMenuOpener(BuildContext context) {
if (!Platform.isMacOS) {
return const SizedBox();
}
return Padding(
padding: const EdgeInsets.only(bottom: 8.0, top: 12.0, left: 12.0),
child: Row(
children: [
Text(
'macOS actions:',
style: TextStyle(
fontSize: 16.0,
color: brightness.getForegroundColor(context),
fontWeight: FontWeight.bold,
),
),
const SizedBox(width: 16.0),
OutlinedButton(
child: Text('show all actions'),
onPressed: () {
showDialog(
context: context,
builder: (_) {
return Theme(
data: brightness.getIsDark(context)
? ThemeData.dark()
: ThemeData.light(),
child: LayoutBuilder(builder: (_, constraints) {
return Center(
child: SizedBox(
width: min(512.0, constraints.maxWidth - 32.0),
height: constraints.maxHeight - 32.0,
child: MacOSActionMenu(
items: [
MacOSActionMenuItem(
name: 'Set Document Edited',
function: () => Window.setDocumentEdited(),
description:
'This will change the appearance of the '
'close button on the titlebar.',
),
MacOSActionMenuItem(
name: 'Set Document Unedited',
function: () => Window.setDocumentUnedited(),
),
MacOSActionMenuItem(
name: 'Set Represented Filename',
function: () =>
Window.setRepresentedFilename('filename'),
),
MacOSActionMenuItem(
name: 'Set Represented URL',
function: () => Window.setRepresentedUrl('url'),
),
MacOSActionMenuItem(
name: 'Hide Title',
function: () => Window.hideTitle(),
),
MacOSActionMenuItem(
name: 'Show Title',
function: () => Window.showTitle(),
),
MacOSActionMenuItem(
name: 'Make Titlebar Transparent',
function: () =>
Window.makeTitlebarTransparent(),
),
MacOSActionMenuItem(
name: 'Make Titlebar Opaque',
function: () => Window.makeTitlebarOpaque(),
),
MacOSActionMenuItem(
name: 'Enable Full Size Content View',
function: () =>
Window.enableFullSizeContentView(),
description:
'This expands the area that Flutter '
'can draw to to fill the entire '
'window. It is recommended to enable '
'the full-size content view when '
'making the titlebar transparent.',
),
MacOSActionMenuItem(
name: 'Disable Full Size Content View',
function: () =>
Window.disableFullSizeContentView(),
),
MacOSActionMenuItem(
name: 'Zoom Window',
function: () => Window.zoomWindow(),
),
MacOSActionMenuItem(
name: 'Unzoom Window',
function: () => Window.unzoomWindow(),
),
MacOSActionMenuItem(
name: 'Hide Zoom Button',
function: () => Window.hideZoomButton(),
),
MacOSActionMenuItem(
name: 'Show Zoom Button',
function: () => Window.showZoomButton(),
),
MacOSActionMenuItem(
name: 'Hide Miniaturize Button',
function: () => Window.hideMiniaturizeButton(),
),
MacOSActionMenuItem(
name: 'Show Miniaturize Button',
function: () => Window.showMiniaturizeButton(),
),
MacOSActionMenuItem(
name: 'Hide Close Button',
function: () => Window.hideCloseButton(),
),
MacOSActionMenuItem(
name: 'Show Close Button',
function: () => Window.showCloseButton(),
),
MacOSActionMenuItem(
name: 'Enable Zoom Button',
function: () => Window.enableZoomButton(),
),
MacOSActionMenuItem(
name: 'Disable Zoom Button',
function: () => Window.disableZoomButton(),
),
MacOSActionMenuItem(
name: 'Enable Miniaturize Button',
function: () =>
Window.enableMiniaturizeButton(),
),
MacOSActionMenuItem(
name: 'Disable Miniaturize Button',
function: () =>
Window.disableMiniaturizeButton(),
),
MacOSActionMenuItem(
name: 'Enable Close Button',
function: () => Window.enableCloseButton(),
),
MacOSActionMenuItem(
name: 'Disable Close Button',
function: () => Window.disableCloseButton(),
),
MacOSActionMenuItem(
name: 'Set Window Alpha Value to 0.5',
function: () => Window.setWindowAlphaValue(0.5),
),
MacOSActionMenuItem(
name: 'Set Window Alpha Value to 0.75',
function: () =>
Window.setWindowAlphaValue(0.75),
),
MacOSActionMenuItem(
name: 'Set Window Alpha Value to 1.0',
function: () => Window.setWindowAlphaValue(1.0),
),
MacOSActionMenuItem(
name: 'Set Window Background Color to Default '
'Color',
function: () => Window
.setWindowBackgroundColorToDefaultColor(),
description:
'Sets the window background color to '
'the default (opaque) window color.',
),
MacOSActionMenuItem(
name: 'Set Window Background Color to Clear',
function: () =>
Window.setWindowBackgroundColorToClear(),
),
MacOSActionMenuItem(
name: 'Set Blur View State to Active',
function: () {
setState(() {
macOSBlurViewState =
MacOSBlurViewState.active;
});
Window.setBlurViewState(
MacOSBlurViewState.active,
);
},
),
MacOSActionMenuItem(
name: 'Set Blur View State to Inactive',
function: () {
setState(
() {
macOSBlurViewState =
MacOSBlurViewState.inactive;
},
);
Window.setBlurViewState(
MacOSBlurViewState.inactive,
);
},
),
MacOSActionMenuItem(
name: 'Set Blur View State to Follows '
'Window Active State',
function: () {
setState(
() {
macOSBlurViewState = MacOSBlurViewState
.followsWindowActiveState;
},
);
Window.setBlurViewState(MacOSBlurViewState
.followsWindowActiveState);
},
),
MacOSActionMenuItem(
name: 'Add Toolbar',
function: () => Window.addToolbar(),
),
MacOSActionMenuItem(
name: 'Remove Toolbar',
function: () => Window.removeToolbar(),
),
MacOSActionMenuItem(
name: 'Set Toolbar Style to Automatic',
function: () => Window.setToolbarStyle(
toolbarStyle: MacOSToolbarStyle.automatic,
),
description:
'For this method to have an effect, the '
'window needs to have had a toolbar '
'added beforehand. This can be achieved '
'using the “Add Toolbar” action.',
),
MacOSActionMenuItem(
name: 'Set Toolbar Style to Expanded',
function: () => Window.setToolbarStyle(
toolbarStyle: MacOSToolbarStyle.expanded,
),
description:
'For this method to have an effect, '
'the window needs to have had a toolbar '
'added beforehand. This can be achieved '
'using the “Add Toolbar” action.',
),
MacOSActionMenuItem(
name: 'Set Toolbar Style to Preference',
function: () => Window.setToolbarStyle(
toolbarStyle: MacOSToolbarStyle.preference,
),
description:
'For this method to have an effect, the '
'window needs to have had a toolbar '
'added beforehand. This can be achieved '
'using the “Add Toolbar” action.',
),
MacOSActionMenuItem(
name: 'Set Toolbar Style to Unified',
function: () => Window.setToolbarStyle(
toolbarStyle: MacOSToolbarStyle.unified,
),
description:
'For this method to have an effect, the '
'window needs to have had a toolbar '
'added beforehand. This can be achieved '
'using the “Add Toolbar” action.',
),
MacOSActionMenuItem(
name: 'Set Toolbar Style to Unified Compact',
function: () => Window.setToolbarStyle(
toolbarStyle:
MacOSToolbarStyle.unifiedCompact,
),
description:
'For this method to have an effect, the '
'window needs to have had a toolbar '
'added beforehand. This can be achieved '
'using the “Add Toolbar” action.',
),
MacOSActionMenuItem(
name: 'Enable Shadow',
function: () => Window.enableShadow(),
),
MacOSActionMenuItem(
name: 'Disable Shadow',
function: () => Window.disableShadow(),
),
MacOSActionMenuItem(
name: 'Invalidate Shadows',
function: () => Window.invalidateShadows(),
description:
'This is a fairly technical action and '
'is included here for completeness\' '
'sake. Normally, it should not be '
'necessary to use it.',
),
MacOSActionMenuItem(
name: 'Add Empty Mask Image',
function: () => Window.addEmptyMaskImage(),
description:
'This will effectively disable the '
'`NSVisualEffectView`\'s effect.\n\n'
'**Warning:** It is recommended to '
'disable the window\'s shadow using '
'`Window.disableShadow()` when using '
'this method. Keeping the shadow '
'enabled when using an empty mask image '
'can cause visual artifacts and '
'performance issues.',
),
MacOSActionMenuItem(
name: 'Remove Mask Image',
function: () => Window.removeMaskImage(),
),
MacOSActionMenuItem(
name: 'Make Window Fully Transparent',
function: () =>
Window.makeWindowFullyTransparent(),
description: 'Makes a window fully transparent '
'(with no blur effect). This is a '
'convenience function which executes:\n'
'```dart\n'
'setWindowBackgroundColorToClear();\n'
'makeTitlebarTransparent();\n'
'addEmptyMaskImage();\n'
'disableShadow();\n```\n**Warning:** '
'When the window is fully transparent, '
'its highlight effect (the thin white '
'line at the top of the window) is '
'still visible. This is considered a '
'bug and may change in a future version.',
),
MacOSActionMenuItem(
name: 'Ignore Mouse Events',
function: () {
Window.ignoreMouseEvents();
Timer(
const Duration(seconds: 5),
() => Window.acknowledgeMouseEvents(),
);
},
description:
'This action can be used to make parts '
'of the window click-through, which may '
'be desirable when used in conjunction '
'with '
'`Window.makeWindowFullyTransparent()`.'
'\n\n**Note:** Executing this action '
'will make this widow click-through, '
'thus making it impossible to perform '
'the “Acknowledge Mouse Events” again. '
'For this reason, the example app '
'automatically starts acknowledging '
'mouse events again after five seconds.',
),
MacOSActionMenuItem(
name: 'Acknowledge Mouse Events',
function: () => Window.acknowledgeMouseEvents(),
description: 'This action is included here for '
'completeness\' sake, however it is '
'technically impossible to run it after '
'performing the “Ignore Mouse Events” '
'action, since the “show all actions” '
'button can then no longer be clicked.',
),
MacOSActionMenuItem(
name: 'Set Subtitle',
function: () => Window.setSubtitle('subtitle'),
),
MacOSActionMenuItem(
name: 'Remove Subtitle',
function: () => Window.setSubtitle(''),
description: 'The action works by setting the '
'subtitle to an empty string using '
'`Window.setSubtitle(\'\')`. There is no '
'method called `Window.removeSubtitle()`.',
),
],
),
),
);
}),
);
},
);
},
),
],
),
);
}
SingleChildScrollView buildEffectMenu(BuildContext context) {
return SingleChildScrollView(
child: Theme(
data: brightness.getIsDark(context)
? ThemeData.dark()
: ThemeData.light(),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: (Platform.isWindows
? WindowEffect.values.take(7)
: WindowEffect.values)
.map(
(effect) => RadioListTile<WindowEffect>(
title: Text(
effect.toString(),
style: TextStyle(
fontSize: 14.0,
color: brightness.getForegroundColor(context),
),
),
value: effect,
groupValue: this.effect,
onChanged: this.setWindowEffect,
),
)
.toList(),
),
),
);
}
}
class WindowTitleBar extends StatelessWidget {
final InterfaceBrightness brightness;
const WindowTitleBar({Key? key, required this.brightness}) : super(key: key);
@override
Widget build(BuildContext context) {
return Platform.isWindows
? Container(
width: MediaQuery.of(context).size.width,
height: 32.0,
color: Colors.transparent,
child: MoveWindow(
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Spacer(),
MinimizeWindowButton(
colors: WindowButtonColors(
iconNormal: brightness == InterfaceBrightness.light
? Colors.black
: Colors.white,
iconMouseDown: brightness == InterfaceBrightness.light
? Colors.black
: Colors.white,
iconMouseOver: brightness == InterfaceBrightness.light
? Colors.black
: Colors.white,
normal: Colors.transparent,
mouseOver: brightness == InterfaceBrightness.light
? Colors.black.withOpacity(0.04)
: Colors.white.withOpacity(0.04),
mouseDown: brightness == InterfaceBrightness.light
? Colors.black.withOpacity(0.08)
: Colors.white.withOpacity(0.08),
),
),
MaximizeWindowButton(
colors: WindowButtonColors(
iconNormal: brightness == InterfaceBrightness.light
? Colors.black
: Colors.white,
iconMouseDown: brightness == InterfaceBrightness.light
? Colors.black
: Colors.white,
iconMouseOver: brightness == InterfaceBrightness.light
? Colors.black
: Colors.white,
normal: Colors.transparent,
mouseOver: brightness == InterfaceBrightness.light
? Colors.black.withOpacity(0.04)
: Colors.white.withOpacity(0.04),
mouseDown: brightness == InterfaceBrightness.light
? Colors.black.withOpacity(0.08)
: Colors.white.withOpacity(0.08),
),
),
CloseWindowButton(
onPressed: () {
appWindow.close();
},
colors: WindowButtonColors(
iconNormal: brightness == InterfaceBrightness.light
? Colors.black
: Colors.white,
iconMouseDown: brightness == InterfaceBrightness.light
? Colors.black
: Colors.white,
iconMouseOver: brightness == InterfaceBrightness.light
? Colors.black
: Colors.white,
normal: Colors.transparent,
mouseOver: brightness == InterfaceBrightness.light
? Colors.black.withOpacity(0.04)
: Colors.white.withOpacity(0.04),
mouseDown: brightness == InterfaceBrightness.light
? Colors.black.withOpacity(0.08)
: Colors.white.withOpacity(0.08),
),
),
],
),
),
)
: Container();
}
}