master #81

Closed
malo wants to merge 322 commits from master into feat/bloc_layout/new-package
5 changed files with 64 additions and 38 deletions
Showing only changes of commit 1af9b0b1f1 - Show all commits

View File

@ -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 <https://www.gnu.org/licenses/>.
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;
}
}
}

View File

@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:dotted_border/dotted_border.dart';
import 'package:flutter/material.dart' hide ButtonStyle; import 'package:flutter/material.dart' hide ButtonStyle;
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:gap/gap.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_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/button_cubit.dart';
import 'package:wyatt_ui_kit/src/components/buttons/cubit/invalid_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/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/components/gradients/gradient_text.dart';
import 'package:wyatt_ui_kit/src/core/helpers/linear_gradient_helper.dart'; import 'package:wyatt_ui_kit/src/core/helpers/linear_gradient_helper.dart';
@ -65,7 +65,7 @@ class FileSelectionButtonScreen
InvalidButtonCubit create(BuildContext context) => InvalidButtonCubit(); InvalidButtonCubit create(BuildContext context) => InvalidButtonCubit();
/// Negotiate the theme to get a complete style. /// Negotiate the theme to get a complete style.
FileSelectionButtonStyle resolve(BuildContext context, ButtonState state) { FileSelectionButtonStyle _resolve(BuildContext context, ButtonState state) {
final FileSelectionButtonThemeResolver resolver = themeResolver ?? final FileSelectionButtonThemeResolver resolver = themeResolver ??
FileSelectionButtonThemeResolver( FileSelectionButtonThemeResolver(
computeExtensionValueFn: ( computeExtensionValueFn: (
@ -135,31 +135,9 @@ class FileSelectionButtonScreen
return resolver.negotiate(context, extra: state); 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 @override
Widget onBuild(BuildContext context, ButtonState state) { Widget onBuild(BuildContext context, ButtonState state) {
final style = resolve(context, state); final style = _resolve(context, state);
return Focus( return Focus(
onFocusChange: (hasFocus) => onFocusChange: (hasFocus) =>
@ -192,10 +170,9 @@ class FileSelectionButtonScreen
onPressed?.call(state.state); onPressed?.call(state.state);
bloc(context).onClickUpOut(); bloc(context).onClickUpOut();
}, },
child: _border( child: DotterBorderChild(
context, style: style,
style, child: DecoratedBox(
DecoratedBox(
decoration: BoxDecoration( decoration: BoxDecoration(
color: style.backgroundColors?.color, color: style.backgroundColors?.color,
// if no gradient colors => no default value // if no gradient colors => no default value
@ -221,7 +198,7 @@ class FileSelectionButtonScreen
children: [ children: [
if (leading != null) ...[ if (leading != null) ...[
leading ?? const SizedBox.shrink(), leading ?? const SizedBox.shrink(),
Gap((style.padding?.horizontal ?? 10)/2), Gap((style.padding?.horizontal ?? 10) / 2),
], ],
Column( Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
@ -237,7 +214,7 @@ class FileSelectionButtonScreen
/// buttonStyle.foregroundColor.colors ?? /// buttonStyle.foregroundColor.colors ??
/// null /// null
/// ///
/// More infos in `negociate()` method /// More infos in `ThemeResolver` class
if (title != null) ...[ if (title != null) ...[
Text( Text(
title!.text, title!.text,
@ -263,7 +240,7 @@ class FileSelectionButtonScreen
/// buttonStyle.foregroundColor.colors ?? /// buttonStyle.foregroundColor.colors ??
/// null /// null
/// ///
/// More infos in `negociate()` method /// More infos in `ThemeResolver` class
if (subTitle != null) ...[ if (subTitle != null) ...[
const Gap(5), const Gap(5),
Text( Text(

View File

@ -59,7 +59,7 @@ class FlatButtonScreen extends CubitScreen<ButtonCubit, ButtonState> {
ButtonCubit create(BuildContext context) => ButtonCubit(); ButtonCubit create(BuildContext context) => ButtonCubit();
/// Negotiate the theme to get a complete style. /// Negotiate the theme to get a complete style.
FlatButtonStyle resolve(BuildContext context, ControlState state) { FlatButtonStyle _resolve(BuildContext context, ControlState state) {
final FlatButtonThemeResolver resolver = themeResolver ?? final FlatButtonThemeResolver resolver = themeResolver ??
FlatButtonThemeResolver( FlatButtonThemeResolver(
computeExtensionValueFn: ( computeExtensionValueFn: (
@ -103,7 +103,7 @@ class FlatButtonScreen extends CubitScreen<ButtonCubit, ButtonState> {
@override @override
Widget onBuild(BuildContext context, ButtonState state) { Widget onBuild(BuildContext context, ButtonState state) {
final style = resolve(context, state.state); final style = _resolve(context, state.state);
return Focus( return Focus(
onFocusChange: (hasFocus) => onFocusChange: (hasFocus) =>

View File

@ -52,7 +52,7 @@ class SimpleIconButtonScreen extends CubitScreen<ButtonCubit, ButtonState> {
ButtonCubit create(BuildContext context) => ButtonCubit(); ButtonCubit create(BuildContext context) => ButtonCubit();
/// Negotiate the theme to get a complete style. /// Negotiate the theme to get a complete style.
SimpleIconButtonStyle resolve(BuildContext context, ControlState state) { SimpleIconButtonStyle _resolve(BuildContext context, ControlState state) {
final SimpleIconButtonThemeResolver resolver = themeResolver ?? final SimpleIconButtonThemeResolver resolver = themeResolver ??
SimpleIconButtonThemeResolver( SimpleIconButtonThemeResolver(
computeExtensionValueFn: ( computeExtensionValueFn: (
@ -96,7 +96,7 @@ class SimpleIconButtonScreen extends CubitScreen<ButtonCubit, ButtonState> {
@override @override
Widget onBuild(BuildContext context, ButtonState state) { Widget onBuild(BuildContext context, ButtonState state) {
final style = resolve(context, state.state); final style = _resolve(context, state.state);
return Focus( return Focus(
onFocusChange: (hasFocus) => onFocusChange: (hasFocus) =>

View File

@ -61,7 +61,7 @@ class SymbolButtonScreen
SelectableButtonCubit create(BuildContext context) => SelectableButtonCubit(); SelectableButtonCubit create(BuildContext context) => SelectableButtonCubit();
/// Negotiate the theme to get a complete style. /// Negotiate the theme to get a complete style.
SymbolButtonStyle resolve(BuildContext context, ButtonState state) { SymbolButtonStyle _resolve(BuildContext context, ButtonState state) {
final SymbolButtonThemeResolver resolver = themeResolver ?? final SymbolButtonThemeResolver resolver = themeResolver ??
SymbolButtonThemeResolver( SymbolButtonThemeResolver(
computeExtensionValueFn: ( computeExtensionValueFn: (
@ -127,7 +127,7 @@ class SymbolButtonScreen
@override @override
Widget onBuild(BuildContext context, ButtonState state) { Widget onBuild(BuildContext context, ButtonState state) {
final style = resolve(context, state); final style = _resolve(context, state);
return Focus( return Focus(
onFocusChange: (hasFocus) => onFocusChange: (hasFocus) =>