Skip to content

Commit a3e9a9d

Browse files
Optional Actions for those of us using it for CrossPlatform
1 parent 808ccd3 commit a3e9a9d

File tree

3 files changed

+88
-87
lines changed

3 files changed

+88
-87
lines changed

Diff for: example/pubspec.lock

+56-24
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ packages:
6161
dependency: transitive
6262
description:
6363
name: collection
64-
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
64+
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
6565
url: "https://pub.dev"
6666
source: hosted
67-
version: "1.17.1"
67+
version: "1.18.0"
6868
dbus:
6969
dependency: transitive
7070
description:
@@ -154,21 +154,37 @@ packages:
154154
url: "https://pub.dev"
155155
source: hosted
156156
version: "4.0.0"
157-
js:
157+
leak_tracker:
158158
dependency: transitive
159159
description:
160-
name: js
161-
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
160+
name: leak_tracker
161+
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
162162
url: "https://pub.dev"
163163
source: hosted
164-
version: "0.6.7"
164+
version: "10.0.0"
165+
leak_tracker_flutter_testing:
166+
dependency: transitive
167+
description:
168+
name: leak_tracker_flutter_testing
169+
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
170+
url: "https://pub.dev"
171+
source: hosted
172+
version: "2.0.1"
173+
leak_tracker_testing:
174+
dependency: transitive
175+
description:
176+
name: leak_tracker_testing
177+
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
178+
url: "https://pub.dev"
179+
source: hosted
180+
version: "2.0.1"
165181
libadwaita:
166182
dependency: "direct main"
167183
description:
168184
path: ".."
169185
relative: true
170186
source: path
171-
version: "2.0.1"
187+
version: "2.0.2"
172188
libadwaita_core:
173189
dependency: transitive
174190
description:
@@ -189,26 +205,26 @@ packages:
189205
dependency: transitive
190206
description:
191207
name: matcher
192-
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
208+
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
193209
url: "https://pub.dev"
194210
source: hosted
195-
version: "0.12.15"
211+
version: "0.12.16+1"
196212
material_color_utilities:
197213
dependency: transitive
198214
description:
199215
name: material_color_utilities
200-
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
216+
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
201217
url: "https://pub.dev"
202218
source: hosted
203-
version: "0.2.0"
219+
version: "0.8.0"
204220
meta:
205221
dependency: transitive
206222
description:
207223
name: meta
208-
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
224+
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
209225
url: "https://pub.dev"
210226
source: hosted
211-
version: "1.9.1"
227+
version: "1.11.0"
212228
package_info_plus:
213229
dependency: transitive
214230
description:
@@ -229,10 +245,10 @@ packages:
229245
dependency: transitive
230246
description:
231247
name: path
232-
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
248+
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
233249
url: "https://pub.dev"
234250
source: hosted
235-
version: "1.8.3"
251+
version: "1.9.0"
236252
path_parsing:
237253
dependency: transitive
238254
description:
@@ -298,26 +314,26 @@ packages:
298314
dependency: transitive
299315
description:
300316
name: source_span
301-
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
317+
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
302318
url: "https://pub.dev"
303319
source: hosted
304-
version: "1.9.1"
320+
version: "1.10.0"
305321
stack_trace:
306322
dependency: transitive
307323
description:
308324
name: stack_trace
309-
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
325+
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
310326
url: "https://pub.dev"
311327
source: hosted
312-
version: "1.11.0"
328+
version: "1.11.1"
313329
stream_channel:
314330
dependency: transitive
315331
description:
316332
name: stream_channel
317-
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
333+
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
318334
url: "https://pub.dev"
319335
source: hosted
320-
version: "2.1.1"
336+
version: "2.1.2"
321337
string_scanner:
322338
dependency: transitive
323339
description:
@@ -338,10 +354,10 @@ packages:
338354
dependency: transitive
339355
description:
340356
name: test_api
341-
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
357+
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
342358
url: "https://pub.dev"
343359
source: hosted
344-
version: "0.5.1"
360+
version: "0.6.1"
345361
typed_data:
346362
dependency: transitive
347363
description:
@@ -350,6 +366,14 @@ packages:
350366
url: "https://pub.dev"
351367
source: hosted
352368
version: "1.3.1"
369+
universal_io:
370+
dependency: transitive
371+
description:
372+
name: universal_io
373+
sha256: "1722b2dcc462b4b2f3ee7d188dad008b6eb4c40bbd03a3de451d82c78bba9aad"
374+
url: "https://pub.dev"
375+
source: hosted
376+
version: "2.2.2"
353377
url_launcher:
354378
dependency: transitive
355379
description:
@@ -454,6 +478,14 @@ packages:
454478
url: "https://pub.dev"
455479
source: hosted
456480
version: "3.0.1"
481+
vm_service:
482+
dependency: transitive
483+
description:
484+
name: vm_service
485+
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
486+
url: "https://pub.dev"
487+
source: hosted
488+
version: "13.0.0"
457489
win32:
458490
dependency: transitive
459491
description:
@@ -487,5 +519,5 @@ packages:
487519
source: hosted
488520
version: "6.3.0"
489521
sdks:
490-
dart: ">=3.0.0-0 <4.0.0"
522+
dart: ">=3.2.0-0 <4.0.0"
491523
flutter: ">=3.7.0-0"

Diff for: lib/src/widgets/adw/header_bar.dart

+24-45
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import 'package:universal_io/io.dart';
2-
31
import 'package:dbus/dbus.dart';
42
import 'package:flutter/foundation.dart';
53
import 'package:flutter/material.dart';
64
import 'package:gsettings/gsettings.dart';
75
import 'package:libadwaita/src/utils/colors.dart';
86
import 'package:libadwaita/src/widgets/widgets.dart';
97
import 'package:libadwaita_core/libadwaita_core.dart';
8+
import 'package:universal_io/io.dart';
109

1110
class HeaderBarStyle {
1211
const HeaderBarStyle({
@@ -53,32 +52,32 @@ class AdwHeaderBar extends StatefulWidget {
5352
this.start = const [],
5453
this.end = const [],
5554
this.style = const HeaderBarStyle(),
56-
required AdwActions actions,
55+
AdwActions? actions,
5756
AdwControls? controls,
5857
}) : closeBtn = controls != null
59-
? controls.closeBtn?.call(actions.onClose)
58+
? controls.closeBtn?.call(actions?.onClose)
6059
: AdwWindowButton(
6160
nativeControls: style.nativeControls,
6261
buttonType: WindowButtonType.close,
63-
onPressed: actions.onClose,
62+
onPressed: actions?.onClose,
6463
),
6564
maximizeBtn = controls != null
66-
? controls.maximizeBtn?.call(actions.onMaximize)
65+
? controls.maximizeBtn?.call(actions?.onMaximize)
6766
: AdwWindowButton(
6867
nativeControls: style.nativeControls,
6968
buttonType: WindowButtonType.maximize,
70-
onPressed: actions.onMaximize,
69+
onPressed: actions?.onMaximize,
7170
),
7271
minimizeBtn = controls != null
73-
? controls.minimizeBtn?.call(actions.onMinimize)
72+
? controls.minimizeBtn?.call(actions?.onMinimize)
7473
: AdwWindowButton(
7574
nativeControls: style.nativeControls,
7675
buttonType: WindowButtonType.minimize,
77-
onPressed: actions.onMinimize,
76+
onPressed: actions?.onMinimize,
7877
),
79-
onHeaderDrag = actions.onHeaderDrag,
80-
onDoubleTap = actions.onDoubleTap,
81-
onRightClick = actions.onRightClick;
78+
onHeaderDrag = actions?.onHeaderDrag,
79+
onDoubleTap = actions?.onDoubleTap,
80+
onRightClick = actions?.onRightClick;
8281

8382
/// The leading widget for the headerbar
8483
final List<Widget> start;
@@ -112,19 +111,13 @@ class AdwHeaderBar extends StatefulWidget {
112111
}
113112

114113
class _AdwHeaderBarState extends State<AdwHeaderBar> {
115-
bool get hasWindowControls =>
116-
widget.closeBtn != null ||
117-
widget.minimizeBtn != null ||
118-
widget.maximizeBtn != null;
114+
bool get hasWindowControls => widget.closeBtn != null || widget.minimizeBtn != null || widget.maximizeBtn != null;
119115

120-
late ValueNotifier<List<String>?> separator =
121-
!widget.style.autoPositionWindowButtons ||
122-
!kIsWeb &&
123-
(Platform.isLinux || Platform.isWindows || Platform.isMacOS)
124-
? ValueNotifier(
125-
['', 'minimize,maximize,close'],
126-
)
127-
: ValueNotifier(null);
116+
late ValueNotifier<List<String>?> separator = !widget.style.autoPositionWindowButtons || !kIsWeb && (Platform.isLinux || Platform.isWindows || Platform.isMacOS)
117+
? ValueNotifier(
118+
['', 'minimize,maximize,close'],
119+
)
120+
: ValueNotifier(null);
128121

129122
@override
130123
void initState() {
@@ -138,10 +131,7 @@ class _AdwHeaderBarState extends State<AdwHeaderBar> {
138131
(e) => e
139132
.split(',')
140133
.where(
141-
(element) =>
142-
element == 'close' ||
143-
element == 'maximize' ||
144-
element == 'minimize',
134+
(element) => element == 'close' || element == 'maximize' || element == 'minimize',
145135
)
146136
.join(','),
147137
);
@@ -156,8 +146,7 @@ class _AdwHeaderBarState extends State<AdwHeaderBar> {
156146

157147
WidgetsBinding.instance.addPostFrameCallback((_) async {
158148
try {
159-
final buttonLayout =
160-
await schema.get('button-layout') as DBusString?;
149+
final buttonLayout = await schema.get('button-layout') as DBusString?;
161150
if (buttonLayout != null) {
162151
updateSep(buttonLayout.value);
163152
}
@@ -187,9 +176,7 @@ class _AdwHeaderBarState extends State<AdwHeaderBar> {
187176
alignment: Alignment.topCenter,
188177
child: Container(
189178
decoration: BoxDecoration(
190-
color: !widget.style.isTransparent
191-
? Theme.of(context).appBarTheme.backgroundColor
192-
: null,
179+
color: !widget.style.isTransparent ? Theme.of(context).appBarTheme.backgroundColor : null,
193180
border: !widget.style.isTransparent
194181
? Border(
195182
bottom: BorderSide(color: context.borderColor),
@@ -215,15 +202,11 @@ class _AdwHeaderBarState extends State<AdwHeaderBar> {
215202
leading: Row(
216203
mainAxisSize: MainAxisSize.min,
217204
children: [
218-
if (hasWindowControls &&
219-
sep != null &&
220-
sep[0].split(',').isNotEmpty) ...[
205+
if (hasWindowControls && sep != null && sep[0].split(',').isNotEmpty) ...[
221206
SizedBox(width: widget.style.titlebarSpace),
222207
for (var i in sep[0].split(','))
223208
if (windowButtons[i] != null) windowButtons[i]!,
224-
if (!widget.style.nativeControls ||
225-
!kIsWeb && Platform.isLinux)
226-
SizedBox(width: widget.style.titlebarSpace),
209+
if (!widget.style.nativeControls || !kIsWeb && Platform.isLinux) SizedBox(width: widget.style.titlebarSpace),
227210
],
228211
...widget.start.map(
229212
(e) => Padding(
@@ -243,15 +226,11 @@ class _AdwHeaderBarState extends State<AdwHeaderBar> {
243226
child: e,
244227
),
245228
),
246-
if (hasWindowControls &&
247-
sep != null &&
248-
sep[1].split(',').isNotEmpty) ...[
229+
if (hasWindowControls && sep != null && sep[1].split(',').isNotEmpty) ...[
249230
SizedBox(width: widget.style.titlebarSpace),
250231
for (var i in sep[1].split(','))
251232
if (windowButtons[i] != null) windowButtons[i]!,
252-
if (!widget.style.nativeControls ||
253-
!kIsWeb && Platform.isLinux)
254-
SizedBox(width: widget.style.titlebarSpace),
233+
if (!widget.style.nativeControls || !kIsWeb && Platform.isLinux) SizedBox(width: widget.style.titlebarSpace),
255234
],
256235
],
257236
),

0 commit comments

Comments
 (0)