Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/src/widgets/colors.dart
Original file line number Diff line number Diff line change
@@ -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);
23 changes: 18 additions & 5 deletions lib/src/widgets/virtual_window_frame.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand Down Expand Up @@ -134,16 +143,20 @@ class _VirtualWindowFrameState extends State<VirtualWindowFrame> {
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: <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,
),
Expand Down
9 changes: 5 additions & 4 deletions lib/src/widgets/window_caption.dart
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -150,7 +151,7 @@ class _WindowCaptionState extends State<WindowCaption> {
widget.backgroundColor ??
(widget.brightness == Brightness.dark
? const Color(0xff1C1C1C)
: Colors.transparent),
: kTransparent),
),
child: Row(
children: [
Expand All @@ -166,8 +167,8 @@ class _WindowCaptionState extends State<WindowCaption> {
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(),
Expand Down
51 changes: 26 additions & 25 deletions lib/src/widgets/window_caption_button.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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