Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update style for Mica and Acrylic #121

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
7 changes: 7 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_acrylic/flutter_acrylic.dart';

import 'package:provider/provider.dart';
import 'package:system_theme/system_theme.dart';
Expand Down Expand Up @@ -53,6 +54,11 @@ void main() async {
[TargetPlatform.windows, TargetPlatform.linux]
.contains(defaultTargetPlatform)) {
await flutter_acrylic.Window.initialize();
await flutter_acrylic.Window.setEffect(
effect: WindowEffect.mica,
dark: darkMode,
);
Kapranov98 marked this conversation as resolved.
Show resolved Hide resolved
Window.hideWindowControls();
}

runApp(const MyApp());
Expand Down Expand Up @@ -85,6 +91,7 @@ class MyApp extends StatelessWidget {
initialRoute: '/',
routes: {'/': (_) => const MyHomePage()},
theme: ThemeData(
micaBackgroundColor: Colors.transparent,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be handled this way. We should check what's the current AppTheme.acrylicEffect to get the best color for each.

When this is transparent, we get a weird effect when it's WindowEffect.disabled

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I understand correctly that then it is better to use this option?
micaBackgroundColor: appTheme.acrylicEffect == WindowEffect.acrylic || appTheme.acrylicEffect == WindowEffect.mica ? Colors.transparent : null,

accentColor: appTheme.color,
brightness: appTheme.mode == ThemeMode.system
? darkMode
Expand Down
11 changes: 7 additions & 4 deletions lib/src/controls/form/combo_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,13 @@ class _ComboboxMenuState<T> extends State<_ComboboxMenu<T>> {
constraints.maxHeight;
return Scrollbar(
isAlwaysShown: isScrollable,
child: ListView(
padding: _kListPadding,
shrinkWrap: true,
children: children,
child: ScrollConfiguration(
behavior: ScrollConfiguration.of(context).copyWith(scrollbars: false),
child: ListView(
padding: _kListPadding,
shrinkWrap: true,
children: children,
),
),
);
},
Expand Down
10 changes: 6 additions & 4 deletions lib/src/controls/form/text_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -590,10 +590,12 @@ class _TextBoxState extends State<TextBox>
final Color cursorColor = theme.inactiveColor;
final Color disabledColor = theme.disabledColor;
final Color backgroundColor = _effectiveFocusNode.hasFocus
? theme.scaffoldBackgroundColor
? theme.brightness.isLight
? Colors.white
: const Color.fromRGBO(30, 30, 30, 0.7)
: AccentColor('normal', const {
'normal': Colors.white,
'dark': Color(0xFF2d2d2d),
'normal': Color.fromRGBO(255, 255, 255, 0.7),
'dark': Color.fromRGBO(255, 255, 255, 0.0605),
}).resolve(context);

final TextStyle placeholderStyle = widget.placeholderStyle ??
Expand Down Expand Up @@ -686,7 +688,7 @@ class _TextBoxState extends State<TextBox>
child: IgnorePointer(
ignoring: !enabled,
child: AnimatedContainer(
duration: theme.fasterAnimationDuration,
duration: const Duration(milliseconds: 0),
Kapranov98 marked this conversation as resolved.
Show resolved Hide resolved
curve: theme.animationCurve,
decoration: BoxDecoration(
borderRadius: radius,
Expand Down
7 changes: 4 additions & 3 deletions lib/src/controls/inputs/buttons/button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Button extends BaseButton {
if (states.isPressing) return 0.0;
return 0.3;
}),
shadowColor: ButtonState.all(theme.shadowColor),
shadowColor: ButtonState.all(const Color.fromRGBO(255, 255, 255, 0.04)),
padding: ButtonState.all(const EdgeInsets.only(
left: 11.0,
top: 5.0,
Expand All @@ -60,12 +60,13 @@ class Button extends BaseButton {
}),
foregroundColor: ButtonState.resolveWith((states) {
if (states.isDisabled) return theme.disabledColor;
return ButtonThemeData.buttonColor(theme.brightness, states).basedOnLuminance().toAccentColor()[
return theme.brightness.isLight ? Colors.black : Colors.white;
/*return ButtonThemeData.buttonColor(theme.brightness, states).basedOnLuminance().toAccentColor()[
states.isPressing
? theme.brightness.isLight
? 'lighter'
: 'dark'
: 'normal'];
: 'normal'];*/
Kapranov98 marked this conversation as resolved.
Show resolved Hide resolved
}),
);
}
Expand Down
12 changes: 6 additions & 6 deletions lib/src/controls/inputs/buttons/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -220,20 +220,20 @@ class ButtonThemeData with Diagnosticable {
late Color color;
if (brightness == Brightness.light) {
if (states.isPressing) {
color = const Color(0xFFf2f2f2);
color = const Color.fromRGBO(249, 249, 249, 0.7);
} else if (states.isHovering) {
color = const Color(0xFFF6F6F6);
color = const Color.fromRGBO(249, 249, 249, 0.8);
} else {
color = Colors.white;
color = const Color.fromRGBO(255, 255, 255, 0.98);
}
return color;
} else {
if (states.isPressing) {
color = const Color(0xFF272727);
color = const Color.fromRGBO(255, 255, 255, 0.0837);
} else if (states.isHovering) {
color = const Color(0xFF323232);
color = const Color.fromRGBO(255, 255, 255, 0.0837);
} else {
color = const Color(0xFF2b2b2b);
color = const Color.fromRGBO(255, 255, 255, 0.0605);
Comment on lines +223 to +236
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel like these colors are correct. @WinXaito what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These colors are taken from Microsoft's Figma guidelines and have been slightly tweaked to better match WinUI.
изображение
изображение

}
return color;
}
Expand Down
15 changes: 7 additions & 8 deletions lib/src/controls/inputs/checkbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class Checkbox extends StatelessWidget {
if (content != null) {
child = Row(mainAxisSize: MainAxisSize.min, children: [
child,
const SizedBox(width: 6.0),
const SizedBox(width: 10.0),
content!,
]);
}
Expand Down Expand Up @@ -260,9 +260,8 @@ class CheckboxThemeData with Diagnosticable {
? const Color.fromRGBO(0, 0, 0, 0.2169)
: const Color.fromRGBO(255, 255, 255, 0.1581),
),
color: states.isHovering
? style.inactiveColor.withOpacity(0.1)
: null,
color:
states.isHovering ? style.inactiveColor.withOpacity(0.1) : null,
borderRadius: radius,
),
),
Expand All @@ -274,10 +273,10 @@ class CheckboxThemeData with Diagnosticable {
),
checkedIconColor: ButtonState.resolveWith((states) {
return !states.isDisabled
? style.checkedColor
: style.brightness.isLight
? Colors.white
: const Color.fromRGBO(255, 255, 255, 0.5302);
? style.checkedColor
: style.brightness.isLight
? Colors.white
: const Color.fromRGBO(255, 255, 255, 0.5302);
}),
uncheckedIconColor: ButtonState.all(Colors.transparent),
icon: FluentIcons.check_mark,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/controls/inputs/dropdown_button.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:fluent_ui/fluent_ui.dart';

const EdgeInsets _kDefaultPadding = EdgeInsets.all(5.0);
const EdgeInsets _kDefaultPadding = EdgeInsets.all(10.0);
const double _kVerticalOffset = 20.0;
const double _kContentWidth = 100.0;

Expand Down Expand Up @@ -91,7 +91,7 @@ class DropDownButton extends StatelessWidget {
if (title != null) title!,
Padding(
padding: EdgeInsets.only(left: padding.left),
child: trailing ?? const Icon(FluentIcons.chevron_down, size: 12),
child: trailing ?? const Icon(FluentIcons.chevron_down, size: 8),
),
];

Expand Down
6 changes: 3 additions & 3 deletions lib/src/controls/inputs/radio_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class RadioButton extends StatelessWidget {
if (content != null) {
child = Row(mainAxisSize: MainAxisSize.min, children: [
child,
const SizedBox(width: 6.0),
const SizedBox(width: 10.0),
content!,
]);
}
Expand Down Expand Up @@ -244,8 +244,8 @@ class RadioButtonThemeData with Diagnosticable {
color: states.isPressing
? backgroundColor
: states.isHovering
? backgroundColor.withOpacity(0.8)
: backgroundColor.withOpacity(0.0),
? style.inactiveColor.withOpacity(0.1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look good on light theme, in my opinion

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the same color on hover as Checkbox and ToggleSwitch
изображение

: null,
border: Border.all(
width: states.isPressing ? 4.5 : 1,
color: !states.isDisabled
Expand Down
5 changes: 3 additions & 2 deletions lib/src/controls/navigation/navigation_view/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class NavigationViewState extends State<NavigationView> {
final NavigationPaneThemeData theme = NavigationPaneTheme.of(context);
final localizations = FluentLocalizations.of(context);
final appBarPadding = EdgeInsets.only(top: widget.appBar?.height ?? 0.0);
final ThemeData style = FluentTheme.of(context);

Widget appBar = () {
if (widget.appBar != null) {
Expand Down Expand Up @@ -336,7 +337,7 @@ class NavigationViewState extends State<NavigationView> {
);
} else if (_compactOverlayOpen) {
return Mica(
backgroundColor: theme.backgroundColor,
backgroundColor: style.navViewPaneBackgroundColor,
elevation: 10.0,
child: Container(
decoration: BoxDecoration(
Expand Down Expand Up @@ -431,7 +432,7 @@ class NavigationViewState extends State<NavigationView> {
child: PrimaryScrollController(
controller: scrollController,
child: Mica(
backgroundColor: theme.backgroundColor,
backgroundColor: style.navViewPaneBackgroundColor,
elevation: 10.0,
child: Container(
decoration: BoxDecoration(
Expand Down
2 changes: 1 addition & 1 deletion lib/src/controls/surfaces/dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class ContentDialogThemeData {
factory ContentDialogThemeData.standard(ThemeData style) {
return ContentDialogThemeData(
decoration: BoxDecoration(
color: style.scaffoldBackgroundColor,
color: style.dialogBackgroundColor,
borderRadius: BorderRadius.circular(12),
boxShadow: kElevationToShadow[8],
),
Expand Down
29 changes: 27 additions & 2 deletions lib/src/styles/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ class ThemeData with Diagnosticable {
final Color scaffoldBackgroundColor;
final Color acrylicBackgroundColor;
final Color micaBackgroundColor;
final Color dialogBackgroundColor;
final Color navViewPaneBackgroundColor;
Kapranov98 marked this conversation as resolved.
Show resolved Hide resolved

final Duration fasterAnimationDuration;
final Duration fastAnimationDuration;
Expand Down Expand Up @@ -225,6 +227,8 @@ class ThemeData with Diagnosticable {
required this.scaffoldBackgroundColor,
required this.acrylicBackgroundColor,
required this.micaBackgroundColor,
required this.dialogBackgroundColor,
required this.navViewPaneBackgroundColor,
required this.buttonTheme,
required this.checkboxTheme,
required this.chipTheme,
Expand Down Expand Up @@ -268,6 +272,8 @@ class ThemeData with Diagnosticable {
Color? scaffoldBackgroundColor,
Color? acrylicBackgroundColor,
Color? micaBackgroundColor,
Color? dialogBackgroundColor,
Color? navViewPaneBackgroundColor,
Color? shadowColor,
Color? uncheckedColor,
Color? checkedColor,
Expand Down Expand Up @@ -316,13 +322,20 @@ class ThemeData with Diagnosticable {
disabledColor ??=
isLight ? const Color(0xFF838383) : Colors.grey[80].withOpacity(0.6);
shadowColor ??= isLight ? Colors.black : Colors.grey[130];
scaffoldBackgroundColor ??=
isLight ? const Color(0xFFf9f9f9) : const Color(0xFF272727);
/*scaffoldBackgroundColor ??=
isLight ? const Color(0xFFf9f9f9) : const Color(0xFF272727);*/
scaffoldBackgroundColor ??= isLight
? const Color.fromRGBO(255, 255, 255, 0.5)
: const Color.fromRGBO(58, 58, 58, 0.2);
acrylicBackgroundColor ??= isLight
? const Color.fromARGB(204, 255, 255, 255)
: const Color(0x7F1e1e1e);
micaBackgroundColor ??=
isLight ? const Color(0xFFf3f3f3) : const Color(0xFF202020);
dialogBackgroundColor ??=
isLight ? const Color(0xFFf9f9f9) : const Color(0xFF272727);
navViewPaneBackgroundColor ??=
isLight ? const Color(0xFFf9f9f9) : const Color(0xFF272727);
uncheckedColor ??= isLight
? const Color.fromRGBO(0, 0, 0, 0.6063)
: const Color.fromRGBO(255, 255, 255, 0.786);
Expand Down Expand Up @@ -383,6 +396,8 @@ class ThemeData with Diagnosticable {
scaffoldBackgroundColor: scaffoldBackgroundColor,
acrylicBackgroundColor: acrylicBackgroundColor,
micaBackgroundColor: micaBackgroundColor,
dialogBackgroundColor: dialogBackgroundColor,
navViewPaneBackgroundColor: navViewPaneBackgroundColor,
shadowColor: shadowColor,
uncheckedColor: uncheckedColor,
checkedColor: checkedColor,
Expand Down Expand Up @@ -424,6 +439,10 @@ class ThemeData with Diagnosticable {
disabledColor: Color.lerp(a.disabledColor, b.disabledColor, t)!,
scaffoldBackgroundColor:
Color.lerp(a.scaffoldBackgroundColor, b.scaffoldBackgroundColor, t)!,
dialogBackgroundColor:
Color.lerp(a.dialogBackgroundColor, b.dialogBackgroundColor, t)!,
navViewPaneBackgroundColor:
Color.lerp(a.dialogBackgroundColor, b.navViewPaneBackgroundColor, t)!,
acrylicBackgroundColor:
Color.lerp(a.acrylicBackgroundColor, b.acrylicBackgroundColor, t)!,
micaBackgroundColor:
Expand Down Expand Up @@ -487,6 +506,8 @@ class ThemeData with Diagnosticable {
Color? scaffoldBackgroundColor,
Color? acrylicBackgroundColor,
Color? micaBackgroundColor,
Color? dialogBackgroundColor,
Color? navViewPaneBackgroundColor,
Color? shadowColor,
Color? uncheckedColor,
Color? checkedColor,
Expand Down Expand Up @@ -536,6 +557,10 @@ class ThemeData with Diagnosticable {
acrylicBackgroundColor:
acrylicBackgroundColor ?? this.acrylicBackgroundColor,
micaBackgroundColor: micaBackgroundColor ?? this.micaBackgroundColor,
dialogBackgroundColor:
dialogBackgroundColor ?? this.dialogBackgroundColor,
navViewPaneBackgroundColor:
navViewPaneBackgroundColor ?? this.navViewPaneBackgroundColor,
fasterAnimationDuration:
fasterAnimationDuration ?? this.fasterAnimationDuration,
fastAnimationDuration:
Expand Down