diff --git a/packages/wyatt_ui_kit/lib/src/components/buttons/file_selection_button/dotter_border_child.dart b/packages/wyatt_ui_kit/lib/src/components/buttons/file_selection_button/dotter_border_child.dart new file mode 100644 index 00000000..bc7f03ae --- /dev/null +++ b/packages/wyatt_ui_kit/lib/src/components/buttons/file_selection_button/dotter_border_child.dart @@ -0,0 +1,49 @@ +// Copyright (C) 2023 WYATT GROUP +// Please see the AUTHORS file for details. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +import 'package:dotted_border/dotted_border.dart'; +import 'package:flutter/material.dart'; +import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart'; + +class DotterBorderChild extends StatelessWidget { + const DotterBorderChild({ + required this.style, + required this.child, + super.key, + }); + + final FileSelectionButtonStyle style; + final Widget child; + + @override + Widget build(BuildContext context) { + if (style.borderColors != null && style.stroke != null) { + return DottedBorder( + padding: EdgeInsets.zero, + dashPattern: const [5, 5], + strokeWidth: style.stroke!, + color: style.borderColors!.color, + borderType: BorderType.RRect, + radius: + style.radius?.resolve(TextDirection.ltr).bottomLeft ?? Radius.zero, + strokeCap: StrokeCap.square, + child: child, + ); + } else { + return child; + } + } +} diff --git a/packages/wyatt_ui_kit/lib/src/components/buttons/file_selection_button/file_selection_button_screen.dart b/packages/wyatt_ui_kit/lib/src/components/buttons/file_selection_button/file_selection_button_screen.dart index b763751c..8f884b51 100644 --- a/packages/wyatt_ui_kit/lib/src/components/buttons/file_selection_button/file_selection_button_screen.dart +++ b/packages/wyatt_ui_kit/lib/src/components/buttons/file_selection_button/file_selection_button_screen.dart @@ -14,7 +14,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -import 'package:dotted_border/dotted_border.dart'; import 'package:flutter/material.dart' hide ButtonStyle; import 'package:flutter/services.dart'; import 'package:gap/gap.dart'; @@ -22,6 +21,7 @@ import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart'; import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart'; import 'package:wyatt_ui_kit/src/components/buttons/cubit/button_cubit.dart'; import 'package:wyatt_ui_kit/src/components/buttons/cubit/invalid_button_cubit.dart'; +import 'package:wyatt_ui_kit/src/components/buttons/file_selection_button/dotter_border_child.dart'; import 'package:wyatt_ui_kit/src/components/buttons/file_selection_button/file_selection_button_theme_resolver.dart'; import 'package:wyatt_ui_kit/src/components/gradients/gradient_text.dart'; import 'package:wyatt_ui_kit/src/core/helpers/linear_gradient_helper.dart'; @@ -65,7 +65,7 @@ class FileSelectionButtonScreen InvalidButtonCubit create(BuildContext context) => InvalidButtonCubit(); /// Negotiate the theme to get a complete style. - FileSelectionButtonStyle resolve(BuildContext context, ButtonState state) { + FileSelectionButtonStyle _resolve(BuildContext context, ButtonState state) { final FileSelectionButtonThemeResolver resolver = themeResolver ?? FileSelectionButtonThemeResolver( computeExtensionValueFn: ( @@ -135,31 +135,9 @@ class FileSelectionButtonScreen return resolver.negotiate(context, extra: state); } - Widget _border( - BuildContext context, - FileSelectionButtonStyle style, - Widget child, - ) { - if (style.borderColors != null && style.stroke != null) { - return DottedBorder( - padding: EdgeInsets.zero, - dashPattern: const [5, 5], - strokeWidth: style.stroke!, - color: style.borderColors!.color, - borderType: BorderType.RRect, - radius: - style.radius?.resolve(TextDirection.ltr).bottomLeft ?? Radius.zero, - strokeCap: StrokeCap.square, - child: child, - ); - } else { - return child; - } - } - @override Widget onBuild(BuildContext context, ButtonState state) { - final style = resolve(context, state); + final style = _resolve(context, state); return Focus( onFocusChange: (hasFocus) => @@ -192,10 +170,9 @@ class FileSelectionButtonScreen onPressed?.call(state.state); bloc(context).onClickUpOut(); }, - child: _border( - context, - style, - DecoratedBox( + child: DotterBorderChild( + style: style, + child: DecoratedBox( decoration: BoxDecoration( color: style.backgroundColors?.color, // if no gradient colors => no default value @@ -221,7 +198,7 @@ class FileSelectionButtonScreen children: [ if (leading != null) ...[ leading ?? const SizedBox.shrink(), - Gap((style.padding?.horizontal ?? 10)/2), + Gap((style.padding?.horizontal ?? 10) / 2), ], Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -237,7 +214,7 @@ class FileSelectionButtonScreen /// buttonStyle.foregroundColor.colors ?? /// null /// - /// More infos in `negociate()` method + /// More infos in `ThemeResolver` class if (title != null) ...[ Text( title!.text, @@ -263,7 +240,7 @@ class FileSelectionButtonScreen /// buttonStyle.foregroundColor.colors ?? /// null /// - /// More infos in `negociate()` method + /// More infos in `ThemeResolver` class if (subTitle != null) ...[ const Gap(5), Text( diff --git a/packages/wyatt_ui_kit/lib/src/components/buttons/flat_button/flat_button_screen.dart b/packages/wyatt_ui_kit/lib/src/components/buttons/flat_button/flat_button_screen.dart index b0803388..178cdb01 100644 --- a/packages/wyatt_ui_kit/lib/src/components/buttons/flat_button/flat_button_screen.dart +++ b/packages/wyatt_ui_kit/lib/src/components/buttons/flat_button/flat_button_screen.dart @@ -59,7 +59,7 @@ class FlatButtonScreen extends CubitScreen { ButtonCubit create(BuildContext context) => ButtonCubit(); /// Negotiate the theme to get a complete style. - FlatButtonStyle resolve(BuildContext context, ControlState state) { + FlatButtonStyle _resolve(BuildContext context, ControlState state) { final FlatButtonThemeResolver resolver = themeResolver ?? FlatButtonThemeResolver( computeExtensionValueFn: ( @@ -103,7 +103,7 @@ class FlatButtonScreen extends CubitScreen { @override Widget onBuild(BuildContext context, ButtonState state) { - final style = resolve(context, state.state); + final style = _resolve(context, state.state); return Focus( onFocusChange: (hasFocus) => diff --git a/packages/wyatt_ui_kit/lib/src/components/buttons/simple_icon_button/simple_icon_screen.dart b/packages/wyatt_ui_kit/lib/src/components/buttons/simple_icon_button/simple_icon_screen.dart index 13ea6b8b..7a38de18 100644 --- a/packages/wyatt_ui_kit/lib/src/components/buttons/simple_icon_button/simple_icon_screen.dart +++ b/packages/wyatt_ui_kit/lib/src/components/buttons/simple_icon_button/simple_icon_screen.dart @@ -52,7 +52,7 @@ class SimpleIconButtonScreen extends CubitScreen { ButtonCubit create(BuildContext context) => ButtonCubit(); /// Negotiate the theme to get a complete style. - SimpleIconButtonStyle resolve(BuildContext context, ControlState state) { + SimpleIconButtonStyle _resolve(BuildContext context, ControlState state) { final SimpleIconButtonThemeResolver resolver = themeResolver ?? SimpleIconButtonThemeResolver( computeExtensionValueFn: ( @@ -96,7 +96,7 @@ class SimpleIconButtonScreen extends CubitScreen { @override Widget onBuild(BuildContext context, ButtonState state) { - final style = resolve(context, state.state); + final style = _resolve(context, state.state); return Focus( onFocusChange: (hasFocus) => diff --git a/packages/wyatt_ui_kit/lib/src/components/buttons/symbol_button/symbol_button_screen.dart b/packages/wyatt_ui_kit/lib/src/components/buttons/symbol_button/symbol_button_screen.dart index 2491b496..547ebf64 100644 --- a/packages/wyatt_ui_kit/lib/src/components/buttons/symbol_button/symbol_button_screen.dart +++ b/packages/wyatt_ui_kit/lib/src/components/buttons/symbol_button/symbol_button_screen.dart @@ -61,7 +61,7 @@ class SymbolButtonScreen SelectableButtonCubit create(BuildContext context) => SelectableButtonCubit(); /// Negotiate the theme to get a complete style. - SymbolButtonStyle resolve(BuildContext context, ButtonState state) { + SymbolButtonStyle _resolve(BuildContext context, ButtonState state) { final SymbolButtonThemeResolver resolver = themeResolver ?? SymbolButtonThemeResolver( computeExtensionValueFn: ( @@ -127,7 +127,7 @@ class SymbolButtonScreen @override Widget onBuild(BuildContext context, ButtonState state) { - final style = resolve(context, state); + final style = _resolve(context, state); return Focus( onFocusChange: (hasFocus) =>