diff --git a/lib/src/widgets/colors.dart b/lib/src/widgets/colors.dart new file mode 100644 index 0000000..85d1c5e --- /dev/null +++ b/lib/src/widgets/colors.dart @@ -0,0 +1,14 @@ +import 'dart:ui' show Color; + +// Internal color constants for the package's widgets. Not exported, so the +// package stays free of any design-system dependency. + +const kBlack = Color(0xFF000000); +const kWhite = Color(0xFFFFFFFF); +const kTransparent = Color(0x00000000); + +/// Default [VirtualWindowFrame] border on a light platform (12% black). +const kFrameBorderLight = Color(0x1F000000); + +/// Default [VirtualWindowFrame] border on a dark platform (12% white). +const kFrameBorderDark = Color(0x1FFFFFFF); diff --git a/lib/src/widgets/virtual_window_frame.dart b/lib/src/widgets/virtual_window_frame.dart index 139ff96..536532f 100644 --- a/lib/src/widgets/virtual_window_frame.dart +++ b/lib/src/widgets/virtual_window_frame.dart @@ -1,7 +1,8 @@ import 'dart:io'; import 'package:flutter/foundation.dart'; -import 'package:material_ui/material_ui.dart'; +import 'package:flutter/widgets.dart'; +import 'package:window_manager/src/widgets/colors.dart'; import 'package:nativeapi/nativeapi.dart' as nativeapi; import 'package:nativeapi_flutter/nativeapi_flutter.dart' show DragToResizeArea; import 'package:window_manager/src/native_guard.dart'; @@ -12,11 +13,19 @@ final _kIsWindows = !kIsWeb && Platform.isWindows; /// Draws the border and shadow of a frameless window, and puts native resize /// handles along its edges. class VirtualWindowFrame extends StatefulWidget { - const VirtualWindowFrame({super.key, required this.child, this.window}); + const VirtualWindowFrame({ + super.key, + required this.child, + this.window, + this.borderColor, + }); /// The [child] contained by the VirtualWindowFrame. final Widget child; + /// The window border color. Defaults to one matching the platform brightness. + final Color? borderColor; + /// The window the resize handles act on. When omitted, resolves the current /// window on interaction. final nativeapi.Window? window; @@ -134,16 +143,20 @@ class _VirtualWindowFrameState extends State { final isFilling = _isMaximized || _isFullScreen; return Container( decoration: BoxDecoration( - color: Colors.transparent, + color: kTransparent, border: Border.all( - color: Theme.of(context).dividerColor, + color: + widget.borderColor ?? + (MediaQuery.maybePlatformBrightnessOf(context) == Brightness.dark + ? kFrameBorderDark + : kFrameBorderLight), width: isFilling ? 0 : 1, ), borderRadius: BorderRadius.circular(isFilling ? 0 : 6), boxShadow: [ if (!isFilling) BoxShadow( - color: Colors.black.withValues(alpha: 0.1), + color: kBlack.withValues(alpha: 0.1), offset: Offset(0.0, _isFocused ? 4 : 2), blurRadius: 6, ), diff --git a/lib/src/widgets/window_caption.dart b/lib/src/widgets/window_caption.dart index ab61987..4c05f32 100644 --- a/lib/src/widgets/window_caption.dart +++ b/lib/src/widgets/window_caption.dart @@ -1,4 +1,5 @@ -import 'package:material_ui/material_ui.dart'; +import 'package:flutter/widgets.dart'; +import 'package:window_manager/src/widgets/colors.dart'; import 'package:nativeapi/nativeapi.dart' as nativeapi; import 'package:nativeapi_flutter/nativeapi_flutter.dart' show DragToMoveArea, MaximizeButtonArea; @@ -150,7 +151,7 @@ class _WindowCaptionState extends State { widget.backgroundColor ?? (widget.brightness == Brightness.dark ? const Color(0xff1C1C1C) - : Colors.transparent), + : kTransparent), ), child: Row( children: [ @@ -166,8 +167,8 @@ class _WindowCaptionState extends State { child: DefaultTextStyle( style: TextStyle( color: widget.brightness == Brightness.light - ? Colors.black.withValues(alpha: 0.8956) - : Colors.white, + ? kBlack.withValues(alpha: 0.8956) + : kWhite, fontSize: 14, ), child: widget.title ?? Container(), diff --git a/lib/src/widgets/window_caption_button.dart b/lib/src/widgets/window_caption_button.dart index 85d652e..74b7ca6 100644 --- a/lib/src/widgets/window_caption_button.dart +++ b/lib/src/widgets/window_caption_button.dart @@ -1,6 +1,7 @@ // ignore_for_file: library_private_types_in_public_api -import 'package:material_ui/material_ui.dart'; +import 'package:flutter/widgets.dart'; +import 'package:window_manager/src/widgets/colors.dart'; const _kIconChromeClose = 'icon_chrome_close'; const _kIconChromeMaximize = 'icon_chrome_maximize'; @@ -331,26 +332,26 @@ class WindowCaptionButton extends StatefulWidget { this.onPressed, }) : iconName = _kIconChromeClose, _lightButtonBgColorScheme = _ButtonBgColorScheme( - normal: Colors.transparent, + normal: kTransparent, hovered: const Color(0xffC42B1C), pressed: const Color(0xffC42B1C).withValues(alpha: 0.9), ), _lightButtonIconColorScheme = _ButtonIconColorScheme( - normal: Colors.black.withValues(alpha: 0.8956), - hovered: Colors.white, - pressed: Colors.white.withValues(alpha: 0.7), - disabled: Colors.black.withValues(alpha: 0.3614), + normal: kBlack.withValues(alpha: 0.8956), + hovered: kWhite, + pressed: kWhite.withValues(alpha: 0.7), + disabled: kBlack.withValues(alpha: 0.3614), ), _darkButtonBgColorScheme = _ButtonBgColorScheme( - normal: Colors.transparent, + normal: kTransparent, hovered: const Color(0xffC42B1C), pressed: const Color(0xffC42B1C).withValues(alpha: 0.9), ), _darkButtonIconColorScheme = _ButtonIconColorScheme( - normal: Colors.white, - hovered: Colors.white, - pressed: Colors.white.withValues(alpha: 0.786), - disabled: Colors.white.withValues(alpha: 0.3628), + normal: kWhite, + hovered: kWhite, + pressed: kWhite.withValues(alpha: 0.786), + disabled: kWhite.withValues(alpha: 0.3628), ); final Brightness? brightness; @@ -369,26 +370,26 @@ class WindowCaptionButton extends StatefulWidget { final bool pressed; _ButtonBgColorScheme _lightButtonBgColorScheme = _ButtonBgColorScheme( - normal: Colors.transparent, - hovered: Colors.black.withValues(alpha: 0.0373), - pressed: Colors.black.withValues(alpha: 0.0241), + normal: kTransparent, + hovered: kBlack.withValues(alpha: 0.0373), + pressed: kBlack.withValues(alpha: 0.0241), ); _ButtonIconColorScheme _lightButtonIconColorScheme = _ButtonIconColorScheme( - normal: Colors.black.withValues(alpha: 0.8956), - hovered: Colors.black.withValues(alpha: 0.8956), - pressed: Colors.black.withValues(alpha: 0.6063), - disabled: Colors.black.withValues(alpha: 0.3614), + normal: kBlack.withValues(alpha: 0.8956), + hovered: kBlack.withValues(alpha: 0.8956), + pressed: kBlack.withValues(alpha: 0.6063), + disabled: kBlack.withValues(alpha: 0.3614), ); _ButtonBgColorScheme _darkButtonBgColorScheme = _ButtonBgColorScheme( - normal: Colors.transparent, - hovered: Colors.white.withValues(alpha: 0.0605), - pressed: Colors.white.withValues(alpha: 0.0419), + normal: kTransparent, + hovered: kWhite.withValues(alpha: 0.0605), + pressed: kWhite.withValues(alpha: 0.0419), ); _ButtonIconColorScheme _darkButtonIconColorScheme = _ButtonIconColorScheme( - normal: Colors.white, - hovered: Colors.white, - pressed: Colors.white.withValues(alpha: 0.786), - disabled: Colors.white.withValues(alpha: 0.3628), + normal: kWhite, + hovered: kWhite, + pressed: kWhite.withValues(alpha: 0.786), + disabled: kWhite.withValues(alpha: 0.3628), ); _ButtonBgColorScheme get buttonBgColorScheme => brightness != Brightness.dark diff --git a/pubspec.yaml b/pubspec.yaml index 73cc5cf..efdab0a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -29,11 +29,11 @@ dependencies: flutter: sdk: flutter ffi: ^2.1.0 - material_ui: ^1.11.0 nativeapi: ^0.6.2 nativeapi_flutter: ^0.6.2 dev_dependencies: flutter_lints: ^6.0.0 + material_ui: ^1.11.0 flutter_test: sdk: flutter