feat(title_bar): window drag support
This commit is contained in:
parent
e5c59720da
commit
3ed153fd37
|
|
@ -2,32 +2,64 @@ import 'package:flutter/material.dart';
|
|||
import 'package:platform_ui/platform_ui.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
class TitleBar extends PlatformAppBar {
|
||||
TitleBar({
|
||||
List<Widget>? actions,
|
||||
super.backgroundColor,
|
||||
super.centerTitle,
|
||||
super.leading,
|
||||
super.leadingWidth,
|
||||
super.title,
|
||||
super.titleSpacing,
|
||||
super.toolbarOpacity,
|
||||
super.toolbarTextStyle,
|
||||
super.titleTextStyle,
|
||||
super.actionsIconTheme,
|
||||
super.automaticallyImplyLeading,
|
||||
super.foregroundColor,
|
||||
super.titleWidth,
|
||||
super.key,
|
||||
}) : super(
|
||||
actions: [
|
||||
...actions ?? [],
|
||||
const PlatformWindowButtons(),
|
||||
],
|
||||
);
|
||||
class TitleBar extends StatelessWidget with PreferredSizeWidget {
|
||||
final List<Widget>? actions;
|
||||
final Widget? leading;
|
||||
final bool automaticallyImplyLeading;
|
||||
final Widget? title;
|
||||
final Color? backgroundColor;
|
||||
final Color? foregroundColor;
|
||||
final IconThemeData? actionsIconTheme;
|
||||
final bool? centerTitle;
|
||||
final double? titleSpacing;
|
||||
final double toolbarOpacity;
|
||||
final double? leadingWidth;
|
||||
final TextStyle? toolbarTextStyle;
|
||||
final TextStyle? titleTextStyle;
|
||||
final double? titleWidth;
|
||||
|
||||
const TitleBar({
|
||||
this.actions,
|
||||
this.leading,
|
||||
this.automaticallyImplyLeading = true,
|
||||
this.title,
|
||||
this.backgroundColor,
|
||||
this.foregroundColor,
|
||||
this.actionsIconTheme,
|
||||
this.centerTitle,
|
||||
this.titleSpacing,
|
||||
this.toolbarOpacity = 1.0,
|
||||
this.leadingWidth,
|
||||
this.toolbarTextStyle,
|
||||
this.titleWidth,
|
||||
this.titleTextStyle,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DragToMoveArea(child: super.build(context));
|
||||
return PlatformAppBar(
|
||||
automaticallyImplyLeading: automaticallyImplyLeading,
|
||||
backgroundColor: backgroundColor,
|
||||
foregroundColor: foregroundColor,
|
||||
centerTitle: centerTitle,
|
||||
actionsIconTheme: actionsIconTheme,
|
||||
leading: leading,
|
||||
leadingWidth: leadingWidth,
|
||||
title: title,
|
||||
titleSpacing: titleSpacing,
|
||||
toolbarOpacity: toolbarOpacity,
|
||||
toolbarTextStyle: toolbarTextStyle,
|
||||
titleTextStyle: titleTextStyle,
|
||||
titleWidth: titleWidth,
|
||||
onDrag: () => windowManager.startDragging(),
|
||||
actions: [
|
||||
...?actions,
|
||||
const PlatformWindowButtons(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ dependencies:
|
|||
platform_ui:
|
||||
git:
|
||||
url: https://github.com/KRTirtho/platform_ui.git
|
||||
ref: 7eb00aef962f282463bc994ca5a6d31cc78f1fe3
|
||||
ref: 073cefb9c419fcb01cbdfd6ca2f9714eec23c83b
|
||||
fluent_ui: ^4.1.2
|
||||
macos_ui: ^1.7.5
|
||||
libadwaita: ^1.2.5
|
||||
|
|
|
|||
Loading…
Reference in New Issue