master #81

Closed
malo wants to merge 322 commits from master into feat/bloc_layout/new-package
7 changed files with 244 additions and 71 deletions
Showing only changes of commit 60126fffc4 - Show all commits

View File

@ -1,24 +1,28 @@
// Copyright (C) 2023 WYATT GROUP // Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details. // Please see the AUTHORS file for details.
// //
// This program is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// any later version. // any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// 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:flutter/material.dart'; import 'package:flutter/material.dart' hide OutlinedButton;
import 'package:gap/gap.dart'; import 'package:gap/gap.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/wyatt_ui_kit.dart'; import 'package:wyatt_ui_kit/wyatt_ui_kit.dart';
const _color1 = Color(0xFF3C97FB);
const _color2 = Color(0xFF446DF4);
const _colors = [_color1, _color2];
class Buttons extends StatelessWidget { class Buttons extends StatelessWidget {
const Buttons({super.key}); const Buttons({super.key});
@ -27,13 +31,42 @@ class Buttons extends StatelessWidget {
children: [ children: [
Text( Text(
'Buttons', 'Buttons',
style: Theme.of(context) style: Theme.of(context).textTheme.titleLarge,
.textTheme
.titleLarge,
), ),
const Gap(20), const Gap(20),
const FlatButton( const OutlinedButton(
label: TextWrapper('text'), label: TextWrapper('Voir notre savoir faire', gradient: _colors),
style: OutlinedButtonStyle(
borderColors: _colors,
stroke: 3,
),
prefix: Icon(
Icons.arrow_forward_rounded,
color: _color1,
),
suffix: Icon(
Icons.arrow_forward_rounded,
color: _color2,
),
),
const Gap(20),
FlatButton(
label: TextWrapper(
'Voir notre savoir faire',
style:
context.textTheme.titleLarge?.copyWith(color: Colors.white),
),
style: const FlatButtonStyle(
borderColors: _colors,
),
prefix: const Icon(
Icons.arrow_forward_rounded,
color: Colors.white,
),
suffix: const Icon(
Icons.arrow_forward_rounded,
color: Colors.white,
),
), ),
], ],
); );

View File

@ -15,3 +15,4 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
export './flat_button/flat_button.dart'; export './flat_button/flat_button.dart';
export './outlined_button/outlined_button.dart';

View File

@ -14,10 +14,10 @@
// 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:flutter/material.dart'; import 'package:flutter/material.dart' hide ButtonStyle;
import 'package:gap/gap.dart';
import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart'; import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.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/gradients/gradient_box_border.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/extensions/theme_extensions.dart'; import 'package:wyatt_ui_kit/src/core/extensions/theme_extensions.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';
@ -31,69 +31,61 @@ class FlatButton extends FlatButtonComponent with $FlatButtonCWMixin {
super.suffix, super.suffix,
super.label, super.label,
super.state, super.state,
super.radius, super.style,
super.padding,
super.borderColors,
super.backgroundColor,
super.shadow,
super.key, super.key,
}); });
@override @override
Widget build(BuildContext context) => ElevatedButton( FlatButtonStyle? get style => super.style as FlatButtonStyle?;
onPressed: () {},
style: ElevatedButton.styleFrom( @override
shape: RoundedRectangleBorder( Widget build(BuildContext context) => Material(
borderRadius: BorderRadius.circular(radius ?? 0),
),
padding: const EdgeInsets.all(0),
),
child: Ink( child: Ink(
decoration: BoxDecoration( decoration: BoxDecoration(
color: backgroundColor ?? color: style?.backgroundColor ??
Theme.of(context).buttonTheme.colorScheme?.onPrimary, Theme.of(context).buttonTheme.colorScheme?.onPrimary,
border: GradientBoxBorder( gradient: LinearGradient(
gradient: LinearGradient( colors: (style?.borderColors != null &&
colors: (borderColors != null && borderColors!.length >= 2) style!.borderColors!.length >= 2)
? borderColors! ? style!.borderColors!
: [ : [
// TODO(hpcl): change this // TODO(hpcl): change this
Theme.of(context).cardColor, Theme.of(context).cardColor,
Theme.of(context).cardColor Theme.of(context).cardColor
], ],
),
width: 1,
), ),
boxShadow: [ boxShadow: [
if (shadow != null) ...[shadow!] if (style?.shadow != null) ...[style!.shadow!]
], ],
borderRadius: BorderRadius.all( borderRadius: BorderRadius.all(
Radius.circular(radius ?? 0), Radius.circular(style?.radius ?? 0),
), ),
), ),
child: Container( child: ConstrainedBox(
constraints: const BoxConstraints( constraints: const BoxConstraints(
minWidth: 88, minWidth: 88,
minHeight: 36, minHeight: 36,
), // min sizes for Material buttons ), // min sizes for Material buttons
alignment: Alignment.center, child: Padding(
child: Row( padding: EdgeInsets.all(style?.padding ?? 0),
children: [ child: Row(
prefix ?? const SizedBox.shrink(), mainAxisSize: mainAxisSize ?? MainAxisSize.min,
if (label != null) ...[ mainAxisAlignment: MainAxisAlignment.spaceBetween,
Text( children: [
label!.text, prefix ?? const SizedBox.shrink(),
style: label!.style ?? context.textTheme.titleLarge, Gap(style?.padding ?? 10),
).toGradient( if (label != null) ...[
LinearGradientHelper.fromNullableColors(label!.gradient), Text(
), label!.text,
style: label!.style ?? context.textTheme.titleLarge,
).toGradient(
LinearGradientHelper.fromNullableColors(label!.gradient),
)
],
Gap(style?.padding ?? 10),
suffix ?? const SizedBox.shrink(),
], ],
const Text( ),
'OK',
textAlign: TextAlign.center,
),
suffix ?? const SizedBox.shrink(),
],
), ),
), ),
), ),

View File

@ -18,17 +18,10 @@ class $FlatButtonCWProxyImpl implements $FlatButtonComponentCWProxy {
@override @override
FlatButton state(ControlState? state) => this(state: state); FlatButton state(ControlState? state) => this(state: state);
@override @override
FlatButton radius(double? radius) => this(radius: radius); FlatButton style(ButtonStyle? style) => this(style: style);
@override @override
FlatButton padding(double? padding) => this(padding: padding); FlatButton mainAxisSize(MainAxisSize? mainAxisSize) =>
@override this(mainAxisSize: mainAxisSize);
FlatButton borderColors(List<Color>? borderColors) =>
this(borderColors: borderColors);
@override
FlatButton backgroundColor(Color? backgroundColor) =>
this(backgroundColor: backgroundColor);
@override
FlatButton shadow(BoxShadow? shadow) => this(shadow: shadow);
@override @override
FlatButton key(Key? key) => this(key: key); FlatButton key(Key? key) => this(key: key);
@override @override
@ -37,14 +30,16 @@ class $FlatButtonCWProxyImpl implements $FlatButtonComponentCWProxy {
Widget? suffix, Widget? suffix,
TextWrapper? label, TextWrapper? label,
ControlState? state, ControlState? state,
double? radius, ButtonStyle? style,
double? padding, MainAxisSize? mainAxisSize,
List<Color>? borderColors,
Color? backgroundColor,
BoxShadow? shadow,
Key? key, Key? key,
}) => }) =>
FlatButton( FlatButton(
prefix: prefix ?? _value.prefix,
suffix: suffix ?? _value.suffix,
label: label ?? _value.label,
state: state ?? _value.state,
style: style ?? _value.style,
key: key ?? _value.key, key: key ?? _value.key,
); );
} }

View File

@ -0,0 +1,98 @@
// 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:flutter/material.dart' hide ButtonStyle;
import 'package:gap/gap.dart';
import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart';
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
import 'package:wyatt_ui_kit/src/components/gradients/gradient_box_border.dart';
import 'package:wyatt_ui_kit/src/components/gradients/gradient_text.dart';
import 'package:wyatt_ui_kit/src/core/extensions/theme_extensions.dart';
import 'package:wyatt_ui_kit/src/core/helpers/linear_gradient_helper.dart';
part 'outlined_button.g.dart';
@ComponentCopyWithExtension()
class OutlinedButton extends OutlinedButtonComponent
with $OutlinedButtonCWMixin {
const OutlinedButton({
super.prefix,
super.suffix,
super.label,
super.state,
super.style,
super.key,
});
@override
OutlinedButtonStyle? get style => super.style as OutlinedButtonStyle?;
@override
Widget build(BuildContext context) => Material(
child: Ink(
decoration: BoxDecoration(
color: style?.backgroundColor ??
Theme.of(context).buttonTheme.colorScheme?.onPrimary,
border: GradientBoxBorder(
gradient: LinearGradient(
colors: (style?.borderColors != null &&
style!.borderColors!.length >= 2)
? style!.borderColors!
: [
// TODO(hpcl): change this
Theme.of(context).cardColor,
Theme.of(context).cardColor
],
),
width: style?.stroke ?? 2,
),
boxShadow: [
if (style?.shadow != null) ...[style!.shadow!]
],
borderRadius: BorderRadius.all(
Radius.circular(style?.radius ?? 0),
),
),
child: ConstrainedBox(
constraints: const BoxConstraints(
minWidth: 88,
minHeight: 36,
), // min sizes for Material buttons
child: Padding(
padding: EdgeInsets.all(style?.padding ?? 0),
child: Row(
mainAxisSize: mainAxisSize ?? MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
prefix ?? const SizedBox.shrink(),
Gap(style?.padding ?? 10),
if (label != null) ...[
Text(
label!.text,
style: label!.style ?? context.textTheme.titleLarge,
).toGradient(
LinearGradientHelper.fromNullableColors(label!.gradient),
)
],
Gap(style?.padding ?? 10),
suffix ?? const SizedBox.shrink(),
],
),
),
),
),
);
}

View File

@ -0,0 +1,50 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'outlined_button.dart';
// **************************************************************************
// ComponentCopyWithGenerator
// **************************************************************************
class $OutlinedButtonCWProxyImpl implements $OutlinedButtonComponentCWProxy {
const $OutlinedButtonCWProxyImpl(this._value);
final OutlinedButton _value;
@override
OutlinedButton prefix(Widget? prefix) => this(prefix: prefix);
@override
OutlinedButton suffix(Widget? suffix) => this(suffix: suffix);
@override
OutlinedButton label(TextWrapper? label) => this(label: label);
@override
OutlinedButton state(ControlState? state) => this(state: state);
@override
OutlinedButton style(ButtonStyle? style) => this(style: style);
@override
OutlinedButton mainAxisSize(MainAxisSize? mainAxisSize) =>
this(mainAxisSize: mainAxisSize);
@override
OutlinedButton key(Key? key) => this(key: key);
@override
OutlinedButton call({
Widget? prefix,
Widget? suffix,
TextWrapper? label,
ControlState? state,
ButtonStyle? style,
MainAxisSize? mainAxisSize,
Key? key,
}) =>
OutlinedButton(
prefix: prefix ?? _value.prefix,
suffix: suffix ?? _value.suffix,
label: label ?? _value.label,
state: state ?? _value.state,
style: style ?? _value.style,
key: key ?? _value.key,
);
}
mixin $OutlinedButtonCWMixin on Component {
$OutlinedButtonComponentCWProxy get copyWith =>
$OutlinedButtonCWProxyImpl(this as OutlinedButton);
}

View File

@ -12,6 +12,10 @@ dependencies:
flutter: { sdk: flutter } flutter: { sdk: flutter }
gap: ^2.0.1 gap: ^2.0.1
flutter_animate: ^3.0.0 flutter_animate: ^3.0.0
wyatt_bloc_helper:
git:
url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git
path: packages/wyatt_bloc_helper
wyatt_component_copy_with_extension: wyatt_component_copy_with_extension:
git: git:
url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git