feat(ui_kit): implement information card (#126)
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Malo Léon 2023-02-10 14:08:04 +01:00
parent ba1c1016e5
commit 5464cd1d40
29 changed files with 1127 additions and 8 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 756 KiB

View File

@ -0,0 +1,21 @@
import 'package:flutter/material.dart';
import 'package:wyatt_ui_kit_example/cards/information_card/information_cards.dart';
class Cards extends StatelessWidget {
const Cards({super.key});
@override
Widget build(BuildContext context) => ListView(
shrinkWrap: true,
children: [
Text(
'Cards',
style: Theme.of(context)
.textTheme
.titleLarge!
.copyWith(color: Colors.white),
),
const InformationCards(),
],
);
}

View File

@ -0,0 +1,152 @@
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
import 'package:wyatt_ui_kit/wyatt_ui_kit.dart';
class InformationCards extends StatelessWidget {
const InformationCards({super.key});
@override
Widget build(BuildContext context) => ListView(
shrinkWrap: true,
children: [
Text(
'Information Cards',
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(color: Colors.white),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
InformationCard(
icons: const [
FlutterLogo(size: 60),
FlutterLogo(size: 60),
FlutterLogo(size: 60),
],
title: const TextWrapper('Flutter'),
subtitle: TextWrapper.text('One single code base.'),
body: TextWrapper.text(
'Cupidatat reprehenderit aliqua eiusmod Lorem. '
'Qui ipsum id ea ea nulla labore aute ullamco aute '
'quis elit ut amet velit. Incididunt fugiat proident '
'proident deserunt tempor Lorem cillum qui do '
'ullamco Lorem magna ipsum. Ullamco cupidatat velit '
'elit sint ex cupidatat ullamco Lorem amet elit '
'ipsum sunt ex voluptate. Eiusmod quis laborum velit '
'excepteur eu commodo consectetur qui exercitation '
'officia consequat ullamco sit adipisicing. Ullamco '
'magna cupidatat Lorem nulla cupidatat voluptate '
'irure ex reprehenderit.',
),
),
const Gap(20),
InformationCard(
background: Center(
child: Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/asset_1.png'),
fit: BoxFit.fitHeight,
alignment: Alignment.centerRight,
),
),
),
),
icons: const [
FlutterLogo(size: 60),
FlutterLogo(size: 60),
],
title: 'Flutter'.wrap(
gradient: [Colors.blue, Colors.green],
),
subtitle: TextWrapper.text('One single code base.'),
body: 'Cupidatat reprehenderit aliqua eiusmod Lorem. '
'Qui ipsum id ea ea nulla labore aute ullamco aute '
'quis elit ut amet velit. Incididunt fugiat proident '
'proident deserunt tempor Lorem cillum qui do '
'ullamco Lorem magna ipsum. Ullamco cupidatat velit '
'elit sint ex cupidatat ullamco Lorem amet elit '
'ipsum sunt ex voluptate. Eiusmod quis laborum velit '
'excepteur eu commodo consectetur qui exercitation '
'officia consequat ullamco sit adipisicing. Ullamco '
'magna cupidatat Lorem nulla cupidatat voluptate '
'irure ex reprehenderit.'
.wrap(),
),
],
),
const Gap(20),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
InformationCard(
icons: const [
FlutterLogo(size: 60),
],
axis: Axis.horizontal,
title: TextWrapper.text('Flutter'),
subtitle: TextWrapper.text('One single code base.'),
body: 'Cupidatat reprehenderit aliqua eiusmod Lorem. '
'Qui ipsum id ea ea nulla labore aute ullamco aute '
'quis elit ut amet velit. Incididunt fugiat proident '
'proident deserunt tempor Lorem cillum qui do '
'ullamco Lorem magna ipsum. Ullamco cupidatat velit '
'elit sint ex cupidatat ullamco Lorem amet elit '
'ipsum sunt ex voluptate. Eiusmod quis laborum velit '
'excepteur eu commodo consectetur qui exercitation '
'officia consequat ullamco sit adipisicing. Ullamco '
'magna cupidatat Lorem nulla cupidatat voluptate '
'irure ex reprehenderit.'
.wrap(
gradient: [
Colors.red,
Colors.orange,
],
),
),
const Gap(20),
InformationCard(
background: Center(
child: Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/asset_1.png'),
fit: BoxFit.fitHeight,
alignment: Alignment.centerRight,
),
),
),
),
icons: const [
FlutterLogo(size: 60),
],
axis: Axis.horizontal,
title: TextWrapper.text('Flutter'),
subtitle: 'One single code base.'.wrap(
gradient: [Colors.blue, Colors.green],
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
body: TextWrapper.text(
'Cupidatat reprehenderit aliqua eiusmod Lorem. '
'Qui ipsum id ea ea nulla labore aute ullamco aute '
'quis elit ut amet velit. Incididunt fugiat proident '
'proident deserunt tempor Lorem cillum qui do '
'ullamco Lorem magna ipsum. Ullamco cupidatat velit '
'elit sint ex cupidatat ullamco Lorem amet elit '
'ipsum sunt ex voluptate. Eiusmod quis laborum velit '
'excepteur eu commodo consectetur qui exercitation '
'officia consequat ullamco sit adipisicing. Ullamco '
'magna cupidatat Lorem nulla cupidatat voluptate '
'irure ex reprehenderit.',
),
),
],
),
],
);
}

View File

@ -14,7 +14,10 @@
// 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/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:wyatt_ui_kit_example/cards/cards.dart';
void main(List<String> args) {
runApp(const App());
@ -26,14 +29,29 @@ class App extends StatelessWidget {
static const String title = 'Wyatt Ui Kit Example';
@override
Widget build(BuildContext context) => MaterialApp(
title: title,
theme: ThemeData(
primarySwatch: Colors.blue,
Widget build(BuildContext context) => CupertinoApp(
localizationsDelegates: const [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
theme: const CupertinoThemeData(
primaryColor: Colors.blue,
),
supportedLocales: const [
Locale('fr', ''),
],
title: title,
home: CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(
middle: Text(title),
),
child: Padding(
padding: const EdgeInsets.all(8),
child: ListView(
shrinkWrap: true,
children: const [Cards()],
),
home: Scaffold(
appBar: AppBar(
title: const Text(title),
),
),
);

View File

@ -10,9 +10,19 @@ environment:
dependencies:
flutter: { sdk: flutter }
flutter_localizations:
sdk: flutter
gap: ^2.0.1
wyatt_ui_kit:
path: "../"
wyatt_ui_components:
git:
url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git
path: packages/wyatt_ui_components
dev_dependencies:
flutter_test: { sdk: flutter }
@ -23,3 +33,6 @@ dev_dependencies:
# The following section is specific to Flutter.
flutter:
uses-material-design: true
assets:
- ./assets/

View File

@ -0,0 +1,17 @@
// 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/>.
export './information_card/information_card.dart';

View File

@ -0,0 +1,93 @@
// 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';
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/cards/information_card/widgets/information_card_horizontal_header.dart';
import 'package:wyatt_ui_kit/src/components/cards/information_card/widgets/information_card_vertical_header.dart';
import 'package:wyatt_ui_kit/src/components/cards/widgets/card_wrapper.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/helpers.dart';
part 'information_card.g.dart';
const _bodyTopSpacing = 25.0;
@ComponentCopyWithExtension()
class InformationCard extends InformationCardComponent
with $InformationCardCWMixin {
const InformationCard({
super.icons,
super.title,
super.subtitle,
super.body,
super.axis,
super.radius,
super.padding,
super.borderColors,
super.backgroundColor,
super.minSize,
super.maxSize = const Size(330, double.infinity),
super.shadow,
super.background,
super.key,
});
@override
Widget build(BuildContext context) => CardWrapper(
background: background,
padding: padding,
backgroundColor: backgroundColor,
borderColors: borderColors,
shadow: shadow,
maxSize: maxSize,
minSize: minSize,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
if (axis == Axis.horizontal) ...[
InformationCardHorizontalHeader(
icons: icons,
axis: axis,
title: title,
subtitle: subtitle,
),
] else if (axis == Axis.vertical) ...[
InformationCardVerticalHeader(
icons: icons,
axis: axis,
title: title,
subtitle: subtitle,
)
],
if (body != null) ...[
const Gap(_bodyTopSpacing),
Text(
body!.text,
style: body!.style ?? context.textTheme.bodyMedium,
).toGradient(
LinearGradientHelper.fromNullableColors(
body!.gradient,
),
),
],
],
),
);
}

View File

@ -0,0 +1,81 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'information_card.dart';
// **************************************************************************
// ComponentCopyWithGenerator
// **************************************************************************
class $InformationCardCWProxyImpl implements $InformationCardComponentCWProxy {
const $InformationCardCWProxyImpl(this._value);
final InformationCard _value;
@override
InformationCard icons(List<Widget>? icons) => this(icons: icons);
@override
InformationCard title(TextWrapper? title) => this(title: title);
@override
InformationCard subtitle(TextWrapper? subtitle) => this(subtitle: subtitle);
@override
InformationCard body(TextWrapper? body) => this(body: body);
@override
InformationCard axis(Axis? axis) => this(axis: axis);
@override
InformationCard radius(double? radius) => this(radius: radius);
@override
InformationCard padding(double? padding) => this(padding: padding);
@override
InformationCard borderColors(List<Color>? borderColors) =>
this(borderColors: borderColors);
@override
InformationCard backgroundColor(Color? backgroundColor) =>
this(backgroundColor: backgroundColor);
@override
InformationCard minSize(Size? minSize) => this(minSize: minSize);
@override
InformationCard maxSize(Size? maxSize) => this(maxSize: maxSize);
@override
InformationCard shadow(BoxShadow? shadow) => this(shadow: shadow);
@override
InformationCard background(Widget? background) =>
this(background: background);
@override
InformationCard key(Key? key) => this(key: key);
@override
InformationCard call({
List<Widget>? icons,
TextWrapper? title,
TextWrapper? subtitle,
TextWrapper? body,
Axis? axis,
double? radius,
double? padding,
List<Color>? borderColors,
Color? backgroundColor,
Size? minSize,
Size? maxSize,
BoxShadow? shadow,
Widget? background,
Key? key,
}) =>
InformationCard(
icons: icons ?? _value.icons,
title: title ?? _value.title,
subtitle: subtitle ?? _value.subtitle,
body: body ?? _value.body,
axis: axis ?? _value.axis,
radius: radius ?? _value.radius,
padding: padding ?? _value.padding,
borderColors: borderColors ?? _value.borderColors,
backgroundColor: backgroundColor ?? _value.backgroundColor,
minSize: minSize ?? _value.minSize,
maxSize: maxSize ?? _value.maxSize,
shadow: shadow ?? _value.shadow,
background: background ?? _value.background,
key: key ?? _value.key,
);
}
mixin $InformationCardCWMixin on Component {
$InformationCardComponentCWProxy get copyWith =>
$InformationCardCWProxyImpl(this as InformationCard);
}

View File

@ -0,0 +1,52 @@
// 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';
import 'package:gap/gap.dart';
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
import 'package:wyatt_ui_kit/src/components/cards/information_card/widgets/information_card_titles.dart';
const _avatarAndTitlesSpacing = 25.0;
class InformationCardHorizontalHeader extends StatelessWidget {
const InformationCardHorizontalHeader({
this.title,
this.subtitle,
this.axis,
this.icons,
super.key,
});
final TextWrapper? title;
final TextWrapper? subtitle;
final Axis? axis;
final List<Widget>? icons;
@override
Widget build(BuildContext context) => Row(
children: [
if (icons?.first != null) ...[
icons!.first,
const Gap(_avatarAndTitlesSpacing),
InformationCardTitles(
title: title,
subtitle: subtitle,
axis: axis,
),
],
],
);
}

View File

@ -0,0 +1,42 @@
// 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';
import 'package:gap/gap.dart';
const _iconSpacing = 25.0;
class InformationCardIcons extends StatelessWidget {
const InformationCardIcons({
super.key,
this.icons,
});
final List<Widget>? icons;
@override
Widget build(BuildContext context) {
final result = <Widget>[];
for (final widget in icons ?? List<Widget>.empty()) {
result.addAll([widget, const Gap(_iconSpacing)]);
}
result.removeLast();
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: result,
);
}
}

View File

@ -0,0 +1,63 @@
// 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';
import 'package:gap/gap.dart';
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.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';
const _titlesLineSpacing = 5.0;
class InformationCardTitles extends StatelessWidget {
const InformationCardTitles({
this.title,
this.subtitle,
this.axis,
super.key,
});
final TextWrapper? title;
final TextWrapper? subtitle;
final Axis? axis;
@override
Widget build(BuildContext context) => Column(
crossAxisAlignment: axis == Axis.horizontal
? CrossAxisAlignment.start
: CrossAxisAlignment.center,
children: [
if (title != null) ...[
Text(
title!.text,
style: title!.style ?? context.textTheme.titleLarge,
).toGradient(
LinearGradientHelper.fromNullableColors(title!.gradient),
),
],
if (subtitle != null) ...[
const Gap(_titlesLineSpacing),
Text(
subtitle!.text,
style: subtitle!.style ?? context.textTheme.titleSmall,
).toGradient(
LinearGradientHelper.fromNullableColors(subtitle!.gradient),
),
],
],
);
}

View File

@ -0,0 +1,55 @@
// 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';
import 'package:gap/gap.dart';
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
import 'package:wyatt_ui_kit/src/components/cards/information_card/widgets/information_card_icons.dart';
import 'package:wyatt_ui_kit/src/components/cards/information_card/widgets/information_card_titles.dart';
const _avatarAndTitlesSpacing = 25.0;
class InformationCardVerticalHeader extends StatelessWidget {
const InformationCardVerticalHeader({
this.title,
this.subtitle,
this.axis,
this.icons,
super.key,
});
final TextWrapper? title;
final TextWrapper? subtitle;
final Axis? axis;
final List<Widget>? icons;
@override
Widget build(BuildContext context) => Column(
children: [
if (icons != null && icons!.isNotEmpty) ...[
InformationCardIcons(
icons: icons,
),
const Gap(_avatarAndTitlesSpacing),
],
InformationCardTitles(
title: title,
subtitle: subtitle,
axis: axis,
),
],
);
}

View File

@ -0,0 +1,124 @@
// 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';
import 'package:wyatt_ui_kit/src/components/gradients/gradient_box_border.dart';
class CardWrapper extends StatefulWidget {
const CardWrapper({
required this.child,
required this.backgroundColor,
required this.borderColors,
required this.shadow,
required this.minSize,
required this.maxSize,
required this.padding,
required this.background,
super.key,
});
final Widget? background;
final Widget child;
final Color? backgroundColor;
final List<Color>? borderColors;
final BoxShadow? shadow;
final Size? minSize;
final Size? maxSize;
final double? padding;
@override
State<CardWrapper> createState() => _CardWrapperState();
}
class _CardWrapperState extends State<CardWrapper> {
Size _cardSize = Size.zero;
final GlobalKey _key = GlobalKey();
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
final RenderObject? renderBox = _key.currentContext?.findRenderObject();
if (renderBox != null) {
setState(() {
_cardSize =
Size(renderBox.paintBounds.width, renderBox.paintBounds.height);
});
}
});
}
Widget _buildChild(Widget child) => (widget.background != null)
? Stack(
alignment: Alignment.center,
children: [
SizedBox(
width: _cardSize.width,
height: _cardSize.height,
child: Center(child: widget.background),
),
Padding(
padding: EdgeInsets.all(
widget.padding ?? 25,
),
child: child,
),
],
)
: Padding(
padding: EdgeInsets.all(
widget.padding ?? 25,
),
child: child,
);
@override
Widget build(BuildContext context) => SelectionArea(
child: DecoratedBox(
key: _key,
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(Radius.circular(12)),
color: widget.backgroundColor ?? Theme.of(context).cardColor,
border: GradientBoxBorder(
gradient: LinearGradient(
colors: (widget.borderColors != null &&
widget.borderColors!.length >= 2)
? widget.borderColors!
: [
Theme.of(context).cardColor,
Theme.of(context).cardColor
],
),
width: 1,
),
boxShadow: [
if (widget.shadow != null) ...[widget.shadow!]
],
),
child: (widget.minSize != null && widget.maxSize != null)
? ConstrainedBox(
constraints: BoxConstraints(
minWidth: widget.minSize!.width,
minHeight: widget.minSize!.height,
maxWidth: widget.maxSize!.width,
maxHeight: widget.maxSize!.height,
),
child: _buildChild(widget.child),
)
: _buildChild(widget.child),
),
);
}

View File

@ -0,0 +1,17 @@
// 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/>.
export './cards/cards.dart';

View File

@ -0,0 +1,85 @@
// 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/painting.dart';
class GradientBoxBorder extends BoxBorder {
const GradientBoxBorder({this.gradient, this.width = 0});
final Gradient? gradient;
final double width;
@override
BorderSide get bottom => BorderSide.none;
@override
BorderSide get top => BorderSide.none;
@override
EdgeInsetsGeometry get dimensions => EdgeInsets.all(width);
@override
bool get isUniform => true;
@override
ShapeBorder scale(double t) => this;
@override
void paint(
Canvas canvas,
Rect rect, {
TextDirection? textDirection,
BoxShape shape = BoxShape.rectangle,
BorderRadius? borderRadius,
}) {
switch (shape) {
case BoxShape.circle:
assert(
borderRadius == null,
'A borderRadius can only be given for rectangular boxes.',
);
_paintCircle(canvas, rect);
break;
case BoxShape.rectangle:
if (borderRadius != null) {
_paintRRect(canvas, rect, borderRadius);
return;
}
_paintRect(canvas, rect);
break;
}
}
Paint _getPaint(Rect rect) => Paint()
..strokeWidth = width
..shader = gradient?.createShader(rect)
..style = PaintingStyle.stroke;
void _paintRect(Canvas canvas, Rect rect) {
canvas.drawRect(rect.deflate(width / 2), _getPaint(rect));
}
void _paintRRect(Canvas canvas, Rect rect, BorderRadius borderRadius) {
final RRect rrect = borderRadius.toRRect(rect).deflate(width / 2);
canvas.drawRRect(rrect, _getPaint(rect));
}
void _paintCircle(Canvas canvas, Rect rect) {
final Paint paint = _getPaint(rect);
final double radius = (rect.shortestSide - width) / 2.0;
canvas.drawCircle(rect.center, radius, paint);
}
}

View File

@ -0,0 +1,71 @@
// 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/widgets.dart';
extension GradientTextExtension on Icon {
GradientIcon toGradient(Gradient? gradient) =>
GradientIcon.from(this, gradient);
}
class GradientIcon extends Icon {
const GradientIcon(
super.icon, {
this.gradient,
super.key,
super.size,
super.fill,
super.weight,
super.grade,
super.opticalSize,
super.color,
super.shadows,
super.semanticLabel,
super.textDirection,
});
factory GradientIcon.from(Icon icon, Gradient? gradient) => GradientIcon(
icon.icon,
gradient: gradient,
key: icon.key,
size: icon.size,
fill: icon.fill,
weight: icon.weight,
grade: icon.grade,
opticalSize: icon.opticalSize,
color: icon.color,
shadows: icon.shadows,
semanticLabel: icon.semanticLabel,
textDirection: icon.textDirection,
);
final Gradient? gradient;
@override
Widget build(BuildContext context) {
if (gradient != null) {
return ShaderMask(
blendMode: BlendMode.srcIn,
shaderCallback: (bounds) => gradient!.createShader(
Rect.fromLTWH(0, 0, bounds.width, bounds.height),
),
child: super.build(context),
);
} else {
return super.build(context);
}
}
}

View File

@ -0,0 +1,81 @@
// Wyatt Studio Copyright (c) 2023
// 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/widgets.dart';
extension GradientTextExtension on Text {
GradientText toGradient(Gradient? gradient) =>
GradientText.from(this, gradient);
}
class GradientText extends Text {
const GradientText(
super.data, {
this.gradient,
super.style,
super.strutStyle,
super.textAlign,
super.textDirection,
super.locale,
super.softWrap,
super.overflow,
super.textScaleFactor,
super.maxLines,
super.semanticsLabel,
super.textWidthBasis,
super.textHeightBehavior,
super.selectionColor,
super.key,
});
factory GradientText.from(Text text, Gradient? gradient) => GradientText(
text.data ?? '',
style: text.style,
gradient: gradient,
strutStyle: text.strutStyle,
textAlign: text.textAlign,
textDirection: text.textDirection,
locale: text.locale,
softWrap: text.softWrap,
overflow: text.overflow,
textScaleFactor: text.textScaleFactor,
maxLines: text.maxLines,
semanticsLabel: text.semanticsLabel,
textWidthBasis: text.textWidthBasis,
textHeightBehavior: text.textHeightBehavior,
selectionColor: text.selectionColor,
key: text.key,
);
final Gradient? gradient;
@override
Widget build(BuildContext context) {
if (gradient != null) {
return ShaderMask(
blendMode: BlendMode.srcIn,
shaderCallback: (bounds) => gradient!.createShader(
Rect.fromLTWH(0, 0, bounds.width, bounds.height),
),
child: super.build(context),
);
} else {
return super.build(context);
}
}
}

View File

@ -0,0 +1,18 @@
// 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/>.
export './extensions/extensions.dart';
export './helpers/helpers.dart';

View File

@ -0,0 +1,17 @@
// 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/>.
export './theme_extensions.dart';

View File

@ -0,0 +1,21 @@
// 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';
extension ThemeExtension on BuildContext {
TextTheme get textTheme => Theme.of(this).textTheme;
}

View File

@ -0,0 +1,17 @@
// 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/>.
export './linear_gradient_helper.dart';

View File

@ -0,0 +1,22 @@
// 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';
class LinearGradientHelper {
static LinearGradient? fromNullableColors(List<Color>? colors) =>
colors != null ? LinearGradient(colors: colors) : null;
}

View File

@ -0,0 +1,34 @@
// 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/>.
// 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/>.
export './components/components.dart';
export './core/core.dart';

View File

@ -16,3 +16,5 @@
/// UIKit and Design System used in Wyatt Studio.
library wyatt_ui_kit;
export './src/src.dart';

View File

@ -3,11 +3,14 @@ description: UIKit and Design System used in Wyatt Studio.
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_ui_kit
version: 1.0.0
publish_to: none
environment:
sdk: ">=2.19.0 <3.0.0"
dependencies:
flutter: { sdk: flutter }
gap: ^2.0.1
flutter_animate: ^3.0.0
wyatt_component_copy_with_extension:
git: