Skip to content

Commit

Permalink
YaruWindowTitleBar: improve defaults for web (#514)
Browse files Browse the repository at this point in the history
Now that we have the "undecorated" style, we can use that on web so
YaruWindowTitleBar becomes a drop-in replacement for AppBar.
  • Loading branch information
jpnurmi committed Jan 14, 2023
1 parent b16e852 commit 3e10c79
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/src/controls/yaru_title_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ class YaruTitleBar extends StatelessWidget implements PreferredSizeWidget {
final FutureOr<void> Function(BuildContext)? onShowMenu;

@override
Size get preferredSize => const Size(0, kYaruTitleBarHeight);
Size get preferredSize =>
Size(0, style == YaruTitleBarStyle.hidden ? 0 : kYaruTitleBarHeight);

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -363,7 +364,8 @@ class YaruWindowTitleBar extends StatelessWidget
final FutureOr<void> Function(BuildContext)? onShowMenu;

@override
Size get preferredSize => const Size(0, kIsWeb ? 0 : kYaruTitleBarHeight);
Size get preferredSize =>
Size(0, style == YaruTitleBarStyle.hidden ? 0 : kYaruTitleBarHeight);

static Future<void> ensureInitialized() => YaruWindow.ensureInitialized();

Expand All @@ -372,7 +374,7 @@ class YaruWindowTitleBar extends StatelessWidget
final theme = YaruTitleBarTheme.of(context);
final style = this.style ??
theme.style ??
(kIsWeb ? YaruTitleBarStyle.hidden : YaruTitleBarStyle.normal);
(kIsWeb ? YaruTitleBarStyle.undecorated : YaruTitleBarStyle.normal);
if (style == YaruTitleBarStyle.hidden) return const SizedBox.shrink();

final defaultState = YaruWindowState(
Expand Down
5 changes: 4 additions & 1 deletion lib/src/layouts/yaru_portrait_layout.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import '../controls/yaru_title_bar_theme.dart';
Expand Down Expand Up @@ -97,7 +98,9 @@ class _YaruPortraitLayoutState extends State<YaruPortraitLayout> {
MaterialPage(
child: YaruTitleBarTheme(
data: const YaruTitleBarThemeData(
style: YaruTitleBarStyle.normal,
style: kIsWeb
? YaruTitleBarStyle.undecorated
: YaruTitleBarStyle.normal,
),
child: Scaffold(
appBar: widget.appBar,
Expand Down

0 comments on commit 3e10c79

Please sign in to comment.