diff --git a/packages/wyatt_ui_kit/example/assets/asset_1.png b/packages/wyatt_ui_kit/example/assets/asset_1.png new file mode 100644 index 00000000..230d42fb Binary files /dev/null and b/packages/wyatt_ui_kit/example/assets/asset_1.png differ diff --git a/packages/wyatt_ui_kit/example/assets/logo.png b/packages/wyatt_ui_kit/example/assets/logo.png new file mode 100644 index 00000000..18eefb0e Binary files /dev/null and b/packages/wyatt_ui_kit/example/assets/logo.png differ diff --git a/packages/wyatt_ui_kit/example/assets/mockup_1.png b/packages/wyatt_ui_kit/example/assets/mockup_1.png new file mode 100644 index 00000000..7d862198 Binary files /dev/null and b/packages/wyatt_ui_kit/example/assets/mockup_1.png differ diff --git a/packages/wyatt_ui_kit/example/assets/mockup_2.png b/packages/wyatt_ui_kit/example/assets/mockup_2.png new file mode 100644 index 00000000..d78e5a88 Binary files /dev/null and b/packages/wyatt_ui_kit/example/assets/mockup_2.png differ diff --git a/packages/wyatt_ui_kit/example/lib/cards/cards.dart b/packages/wyatt_ui_kit/example/lib/cards/cards.dart new file mode 100644 index 00000000..9915af69 --- /dev/null +++ b/packages/wyatt_ui_kit/example/lib/cards/cards.dart @@ -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(), + ], + ); +} diff --git a/packages/wyatt_ui_kit/example/lib/cards/information_card/information_cards.dart b/packages/wyatt_ui_kit/example/lib/cards/information_card/information_cards.dart new file mode 100644 index 00000000..75196e6a --- /dev/null +++ b/packages/wyatt_ui_kit/example/lib/cards/information_card/information_cards.dart @@ -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.', + ), + ), + ], + ), + ], + ); +} diff --git a/packages/wyatt_ui_kit/example/lib/main.dart b/packages/wyatt_ui_kit/example/lib/main.dart index 1b8dc3bf..b4a6308f 100644 --- a/packages/wyatt_ui_kit/example/lib/main.dart +++ b/packages/wyatt_ui_kit/example/lib/main.dart @@ -14,7 +14,10 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +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 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, ), - home: Scaffold( - appBar: AppBar( - title: const Text(title), + 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()], + ), ), ), ); diff --git a/packages/wyatt_ui_kit/example/pubspec.yaml b/packages/wyatt_ui_kit/example/pubspec.yaml index 1f5a0745..1681e8b3 100644 --- a/packages/wyatt_ui_kit/example/pubspec.yaml +++ b/packages/wyatt_ui_kit/example/pubspec.yaml @@ -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/ diff --git a/packages/wyatt_ui_kit/lib/src/components/cards/cards.dart b/packages/wyatt_ui_kit/lib/src/components/cards/cards.dart new file mode 100644 index 00000000..29a2da59 --- /dev/null +++ b/packages/wyatt_ui_kit/lib/src/components/cards/cards.dart @@ -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 . + +export './information_card/information_card.dart'; diff --git a/packages/wyatt_ui_kit/lib/src/components/cards/information_card/information_card.dart b/packages/wyatt_ui_kit/lib/src/components/cards/information_card/information_card.dart new file mode 100644 index 00000000..f52131ba --- /dev/null +++ b/packages/wyatt_ui_kit/lib/src/components/cards/information_card/information_card.dart @@ -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 . + +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, + ), + ), + ], + ], + ), + ); +} diff --git a/packages/wyatt_ui_kit/lib/src/components/cards/information_card/information_card.g.dart b/packages/wyatt_ui_kit/lib/src/components/cards/information_card/information_card.g.dart new file mode 100644 index 00000000..6540af1b --- /dev/null +++ b/packages/wyatt_ui_kit/lib/src/components/cards/information_card/information_card.g.dart @@ -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? 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? 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? icons, + TextWrapper? title, + TextWrapper? subtitle, + TextWrapper? body, + Axis? axis, + double? radius, + double? padding, + List? 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); +} diff --git a/packages/wyatt_ui_kit/lib/src/components/cards/information_card/widgets/information_card_horizontal_header.dart b/packages/wyatt_ui_kit/lib/src/components/cards/information_card/widgets/information_card_horizontal_header.dart new file mode 100644 index 00000000..cc438603 --- /dev/null +++ b/packages/wyatt_ui_kit/lib/src/components/cards/information_card/widgets/information_card_horizontal_header.dart @@ -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 . + +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? icons; + + @override + Widget build(BuildContext context) => Row( + children: [ + if (icons?.first != null) ...[ + icons!.first, + const Gap(_avatarAndTitlesSpacing), + InformationCardTitles( + title: title, + subtitle: subtitle, + axis: axis, + ), + ], + ], + ); +} diff --git a/packages/wyatt_ui_kit/lib/src/components/cards/information_card/widgets/information_card_icons.dart b/packages/wyatt_ui_kit/lib/src/components/cards/information_card/widgets/information_card_icons.dart new file mode 100644 index 00000000..7e4d2bdf --- /dev/null +++ b/packages/wyatt_ui_kit/lib/src/components/cards/information_card/widgets/information_card_icons.dart @@ -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 . + +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? icons; + + @override + Widget build(BuildContext context) { + final result = []; + for (final widget in icons ?? List.empty()) { + result.addAll([widget, const Gap(_iconSpacing)]); + } + result.removeLast(); + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: result, + ); + } +} diff --git a/packages/wyatt_ui_kit/lib/src/components/cards/information_card/widgets/information_card_titles.dart b/packages/wyatt_ui_kit/lib/src/components/cards/information_card/widgets/information_card_titles.dart new file mode 100644 index 00000000..153110eb --- /dev/null +++ b/packages/wyatt_ui_kit/lib/src/components/cards/information_card/widgets/information_card_titles.dart @@ -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 . + +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), + ), + ], + ], + ); +} diff --git a/packages/wyatt_ui_kit/lib/src/components/cards/information_card/widgets/information_card_vertical_header.dart b/packages/wyatt_ui_kit/lib/src/components/cards/information_card/widgets/information_card_vertical_header.dart new file mode 100644 index 00000000..409d43bf --- /dev/null +++ b/packages/wyatt_ui_kit/lib/src/components/cards/information_card/widgets/information_card_vertical_header.dart @@ -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 . + +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? 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, + ), + ], + ); +} diff --git a/packages/wyatt_ui_kit/lib/src/components/cards/widgets/card_wrapper.dart b/packages/wyatt_ui_kit/lib/src/components/cards/widgets/card_wrapper.dart new file mode 100644 index 00000000..1acbda5f --- /dev/null +++ b/packages/wyatt_ui_kit/lib/src/components/cards/widgets/card_wrapper.dart @@ -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 . + +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? borderColors; + final BoxShadow? shadow; + final Size? minSize; + final Size? maxSize; + final double? padding; + + @override + State createState() => _CardWrapperState(); +} + +class _CardWrapperState extends State { + 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), + ), + ); +} diff --git a/packages/wyatt_ui_kit/lib/src/components/components.dart b/packages/wyatt_ui_kit/lib/src/components/components.dart new file mode 100644 index 00000000..75c4ba26 --- /dev/null +++ b/packages/wyatt_ui_kit/lib/src/components/components.dart @@ -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 . + +export './cards/cards.dart'; diff --git a/packages/wyatt_ui_kit/lib/src/components/gradients/gradient_box_border.dart b/packages/wyatt_ui_kit/lib/src/components/gradients/gradient_box_border.dart new file mode 100644 index 00000000..36941942 --- /dev/null +++ b/packages/wyatt_ui_kit/lib/src/components/gradients/gradient_box_border.dart @@ -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 . + +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); + } +} diff --git a/packages/wyatt_ui_kit/lib/src/components/gradients/gradient_icon.dart b/packages/wyatt_ui_kit/lib/src/components/gradients/gradient_icon.dart new file mode 100644 index 00000000..6f7864e3 --- /dev/null +++ b/packages/wyatt_ui_kit/lib/src/components/gradients/gradient_icon.dart @@ -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 . + +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); + } + } +} diff --git a/packages/wyatt_ui_kit/lib/src/components/gradients/gradient_text.dart b/packages/wyatt_ui_kit/lib/src/components/gradients/gradient_text.dart new file mode 100644 index 00000000..0bed20a9 --- /dev/null +++ b/packages/wyatt_ui_kit/lib/src/components/gradients/gradient_text.dart @@ -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 . + +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); + } + } +} diff --git a/packages/wyatt_ui_kit/lib/src/core/core.dart b/packages/wyatt_ui_kit/lib/src/core/core.dart new file mode 100644 index 00000000..f2c1fbdc --- /dev/null +++ b/packages/wyatt_ui_kit/lib/src/core/core.dart @@ -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 . + +export './extensions/extensions.dart'; +export './helpers/helpers.dart'; diff --git a/packages/wyatt_ui_kit/lib/src/core/extensions/extensions.dart b/packages/wyatt_ui_kit/lib/src/core/extensions/extensions.dart new file mode 100644 index 00000000..9680493a --- /dev/null +++ b/packages/wyatt_ui_kit/lib/src/core/extensions/extensions.dart @@ -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 . + +export './theme_extensions.dart'; diff --git a/packages/wyatt_ui_kit/lib/src/core/extensions/theme_extensions.dart b/packages/wyatt_ui_kit/lib/src/core/extensions/theme_extensions.dart new file mode 100644 index 00000000..2cf2e32c --- /dev/null +++ b/packages/wyatt_ui_kit/lib/src/core/extensions/theme_extensions.dart @@ -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 . + +import 'package:flutter/material.dart'; + +extension ThemeExtension on BuildContext { + TextTheme get textTheme => Theme.of(this).textTheme; +} diff --git a/packages/wyatt_ui_kit/lib/src/core/helpers/helpers.dart b/packages/wyatt_ui_kit/lib/src/core/helpers/helpers.dart new file mode 100644 index 00000000..35d48e7f --- /dev/null +++ b/packages/wyatt_ui_kit/lib/src/core/helpers/helpers.dart @@ -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 . + +export './linear_gradient_helper.dart'; diff --git a/packages/wyatt_ui_kit/lib/src/core/helpers/linear_gradient_helper.dart b/packages/wyatt_ui_kit/lib/src/core/helpers/linear_gradient_helper.dart new file mode 100644 index 00000000..7e3af2cd --- /dev/null +++ b/packages/wyatt_ui_kit/lib/src/core/helpers/linear_gradient_helper.dart @@ -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 . + +import 'package:flutter/material.dart'; + +class LinearGradientHelper { + static LinearGradient? fromNullableColors(List? colors) => + colors != null ? LinearGradient(colors: colors) : null; +} diff --git a/packages/wyatt_ui_kit/lib/src/src.dart b/packages/wyatt_ui_kit/lib/src/src.dart new file mode 100644 index 00000000..eb5aa8b4 --- /dev/null +++ b/packages/wyatt_ui_kit/lib/src/src.dart @@ -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 . + +// 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 . + +export './components/components.dart'; +export './core/core.dart'; diff --git a/packages/wyatt_ui_kit/lib/wyatt_ui_kit.dart b/packages/wyatt_ui_kit/lib/wyatt_ui_kit.dart index 004e7a9e..815ae892 100644 --- a/packages/wyatt_ui_kit/lib/wyatt_ui_kit.dart +++ b/packages/wyatt_ui_kit/lib/wyatt_ui_kit.dart @@ -16,3 +16,5 @@ /// UIKit and Design System used in Wyatt Studio. library wyatt_ui_kit; + +export './src/src.dart'; diff --git a/packages/wyatt_ui_kit/pubspec.yaml b/packages/wyatt_ui_kit/pubspec.yaml index 15d313a8..083d7fa6 100644 --- a/packages/wyatt_ui_kit/pubspec.yaml +++ b/packages/wyatt_ui_kit/pubspec.yaml @@ -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: diff --git a/packages/wyatt_ui_kit/test/wyatt_ui_kit_test.dart b/packages/wyatt_ui_kit/test/wyatt_ui_kit_test.dart index 771213c1..3a06c0e1 100644 --- a/packages/wyatt_ui_kit/test/wyatt_ui_kit_test.dart +++ b/packages/wyatt_ui_kit/test/wyatt_ui_kit_test.dart @@ -1 +1 @@ -// TODO(wyatt): add some tests \ No newline at end of file +// TODO(wyatt): add some tests