Fladder/lib/widgets/navigation_scaffold/components/fladder_app_bar.dart
PartyDonut e7b5bb40ff
feat: UI 2.0 and other Improvements (#357)
Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
2025-06-01 10:37:19 +02:00

61 lines
1.8 KiB
Dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:auto_route/auto_route.dart';
import 'package:fladder/screens/shared/default_title_bar.dart';
import 'package:fladder/util/adaptive_layout/adaptive_layout.dart';
bool get _isDesktop {
if (kIsWeb) return false;
return [
TargetPlatform.windows,
TargetPlatform.linux,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
}
class FladderAppBar extends StatelessWidget implements PreferredSize {
final double height;
final String? label;
final bool automaticallyImplyLeading;
const FladderAppBar({this.height = 35, this.automaticallyImplyLeading = false, this.label, super.key});
@override
Widget build(BuildContext context) {
if (AdaptiveLayout.of(context).isDesktop) {
return PreferredSize(
preferredSize: Size(double.infinity, height),
child: SizedBox(
height: height,
child: Row(
children: [
if (automaticallyImplyLeading && context.router.canPop()) const BackButton(),
Expanded(
child: DefaultTitleBar(
label: label,
),
)
],
),
));
} else {
return AppBar(
toolbarHeight: 0,
backgroundColor: Theme.of(context).colorScheme.surface.withValues(alpha: 0),
scrolledUnderElevation: 0,
elevation: 0,
systemOverlayStyle: const SystemUiOverlayStyle(),
title: const Text(""),
automaticallyImplyLeading: automaticallyImplyLeading,
);
}
}
@override
Widget get child => Container();
@override
Size get preferredSize => Size(double.infinity, _isDesktop ? height : 0);
}