docs(ui_layout): add some documentation + readme

This commit is contained in:
Hugo Pointcheval 2023-04-13 22:54:26 +02:00
parent 56de994e67
commit 79c5aa7c76
Signed by: hugo
GPG Key ID: 3AAC487E131E00BC
9 changed files with 69 additions and 97 deletions

View File

@ -16,12 +16,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
--> -->
# Flutter - Wyatt Ui Layout # Wyatt UI Layout
<p align="left"> <p align="left">
<a href="https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_analysis"> <a href="https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_analysis"><img src="https://img.shields.io/badge/Style-Wyatt%20Analysis-blue.svg?style=flat-square" alt="Style: Wyatt Analysis" /></a>
<img src="https://img.shields.io/badge/Style-Wyatt%20Analysis-blue.svg?style=flat-square" alt="Style: Wyatt Analysis" />
</a>
<img src="https://img.shields.io/badge/SDK-Flutter-blue?style=flat-square" alt="SDK: Flutter" /> <img src="https://img.shields.io/badge/SDK-Flutter-blue?style=flat-square" alt="SDK: Flutter" />
</p> </p>
@ -31,19 +29,19 @@ Wyatt UI Layout is a Flutter package that provides pre-built layouts to make the
Structural layouts are used to structure the GUI, and there are currently four layouts provided by this package: Structural layouts are used to structure the GUI, and there are currently four layouts provided by this package:
- #### TopAppBarLayout * #### TopAppBarLayout
This layout is used to create a GUI with a classic app bar and a body. This layout is used to create a GUI with a classic app bar and a body.
- #### TopNavigationBarLayout * #### TopNavigationBarLayout
This layout is used to create a GUI with an app bar that includes navigation options and a body. This layout is used to create a GUI with an app bar that includes navigation options and a body.
- #### BottomNavigationBarLayout * #### BottomNavigationBarLayout
This layout is used to create a GUI with a bottom bar that includes navigation options and a body. This layout is used to create a GUI with a bottom bar that includes navigation options and a body.
- #### FrameLayout * #### FrameLayout
This layout is used to create a GUI that includes a classic app bar, a bottom navigation bar, and a body. This layout is used to create a GUI that includes a classic app bar, a bottom navigation bar, and a body.
@ -51,19 +49,6 @@ This layout is used to create a GUI that includes a classic app bar, a bottom na
Content layouts are used to display dynamic data and content within the GUI. Currently, there is only one content layout provided by this package: Content layouts are used to display dynamic data and content within the GUI. Currently, there is only one content layout provided by this package:
- #### GridLayout * #### GridLayout
This layout is used to display data and content in a grid layout. This layout is used to display data and content in a grid layout.
### Installation
To use Wyatt UI Layout in your Flutter project, add the following dependency to your pubspec.yaml file:
```yaml
wyatt_ui_layout:
git:
url: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages
path: packages/wyatt_ui_layout
```
That's it! You're now ready to use Wyatt UI Layout in your project.

View File

@ -1,19 +1,2 @@
# Copyright (C) 2022 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/>.
include: package:wyatt_analysis/analysis_options.flutter.yaml include: package:wyatt_analysis/analysis_options.flutter.yaml

View File

@ -18,7 +18,12 @@ import 'package:flutter/material.dart';
import 'package:gap/gap.dart'; import 'package:gap/gap.dart';
import 'package:wyatt_ui_layout/src/presentation/layouts/layout.dart'; import 'package:wyatt_ui_layout/src/presentation/layouts/layout.dart';
/// {@template grid_layout}
/// A concrete implementation of the [ContentLayout] abstract class for a layout
/// which defines a layout structure with a grid layout.
/// {@endtemplate}
class GridLayout extends ContentLayout { class GridLayout extends ContentLayout {
/// {@macro grid_layout}
const GridLayout({ const GridLayout({
required this.children, required this.children,
this.verticalGap = 30, this.verticalGap = 30,
@ -26,8 +31,13 @@ class GridLayout extends ContentLayout {
super.key, super.key,
}); });
/// The children of the layout.
final List<Widget> children; final List<Widget> children;
/// The vertical gap between the children.
final double verticalGap; final double verticalGap;
/// The horizontal gap between the children.
final double horizontalGap; final double horizontalGap;
@override @override

View File

@ -1,4 +1,4 @@
// Copyright (C) 2022 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
@ -14,28 +14,35 @@
// 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/>.
/// This file contains the [Layout] abstract class, which provides a base import 'package:flutter/widgets.dart';
/// for creating custom layout widgets in Flutter.
import 'package:flutter/material.dart';
/// {@template layout}
/// An abstract class that provides a base for creating custom layout widgets. /// An abstract class that provides a base for creating custom layout widgets.
/// ///
/// This class can be used as a base for creating custom layout widgets in /// This class can be used as a base for creating custom layout widgets in
/// Flutter. It extends the [StatelessWidget] class and adds support for /// Flutter. It extends the [StatelessWidget] class and adds support for
/// providing a custom key. Custom layout widgets that extend this class should /// providing a custom key. Custom layout widgets that extend this class should
/// override the [build] method to define the layout. /// override the [build] method to define the layout.
/// {@endtemplate}
abstract class Layout extends StatelessWidget { abstract class Layout extends StatelessWidget {
/// Creates a new [Layout] instance. /// {@macro layout}
///
/// [key] is an optional parameter that can be used to provide a custom key
/// for the widget.
const Layout({super.key}); const Layout({super.key});
} }
/// {@template structural_layout}
/// An abstract class that provides a base for creating custom structural layout
/// widgets.
/// {@endtemplate}
abstract class StructuralLayout extends Layout { abstract class StructuralLayout extends Layout {
/// {@macro structural_layout}
const StructuralLayout({super.key}); const StructuralLayout({super.key});
} }
/// {@template content_layout}
/// An abstract class that provides a base for creating custom content layout
/// widgets.
/// {@endtemplate}
abstract class ContentLayout extends Layout { abstract class ContentLayout extends Layout {
/// {@macro content_layout}
const ContentLayout({super.key}); const ContentLayout({super.key});
} }

View File

@ -14,34 +14,27 @@
// 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/>.
/// This file contains the concrete class [BottomNavigationBarLayout].
///
/// The [BottomNavigationBarLayout] class is a concrete implementation of the
/// [Layout] abstract class, which defines a layout structure with a bottom
/// navigation bar component.
///
/// [BottomNavigationBarLayout] includes an optional
/// [BottomNavigationBarLayout.custom]
/// function for customizing the bottom navigation bar component.
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:wyatt_ui_components/wyatt_ui_components.dart'; import 'package:wyatt_ui_components/wyatt_ui_components.dart';
import 'package:wyatt_ui_layout/src/presentation/layouts/layout.dart'; import 'package:wyatt_ui_layout/src/presentation/layouts/layout.dart';
/// A concrete implementation of the [Layout] abstract class for a layout with /// {@template bottom_navigation_bar_layout}
/// a bottom navigation bar component. /// A concrete implementation of the [Layout] abstract class for a layout which
/// defines a layout structure with a bottom navigation bar component.
/// {@endtemplate}
class BottomNavigationBarLayout extends StructuralLayout { class BottomNavigationBarLayout extends StructuralLayout {
/// Creates a [BottomNavigationBarLayout] instance. /// {@macro bottom_navigation_bar_layout}
///
/// [body] represents the main content of the layout.
/// [custom] is an optional function that can be used to customize
/// the bottom navigation bar component.
const BottomNavigationBarLayout({ const BottomNavigationBarLayout({
required this.body, required this.body,
this.custom, this.custom,
super.key, super.key,
}); });
/// The main content of the layout.
final Widget? body; final Widget? body;
/// An optional function that can be used to customize the bottom navigation
/// bar component.
final BottomNavigationBarComponent? Function(BottomNavigationBarComponent?)? final BottomNavigationBarComponent? Function(BottomNavigationBarComponent?)?
custom; custom;

View File

@ -18,6 +18,7 @@ import 'package:flutter/material.dart';
import 'package:wyatt_ui_components/wyatt_ui_components.dart'; import 'package:wyatt_ui_components/wyatt_ui_components.dart';
import 'package:wyatt_ui_layout/src/presentation/layouts/layout.dart'; import 'package:wyatt_ui_layout/src/presentation/layouts/layout.dart';
/// {@template frame_layout}
/// A layout that contains a top app bar, a body and a bottom navigation bar. /// A layout that contains a top app bar, a body and a bottom navigation bar.
/// ///
/// This layout consists of a [TopAppBarComponent] at the top of the screen, /// This layout consists of a [TopAppBarComponent] at the top of the screen,
@ -25,15 +26,9 @@ import 'package:wyatt_ui_layout/src/presentation/layouts/layout.dart';
/// You can customize the app bar and the bottom navigation bar by passing /// You can customize the app bar and the bottom navigation bar by passing
/// a [customAppBar] and a [customBottomNavBar] functions that take /// a [customAppBar] and a [customBottomNavBar] functions that take
/// the corresponding components and return the customized ones. /// the corresponding components and return the customized ones.
/// {@endtemplate}
class FrameLayout extends StructuralLayout { class FrameLayout extends StructuralLayout {
/// Creates a [FrameLayout] instance. /// {@macro frame_layout}
///
/// [body] represents the main content of the layout.
/// [customAppBar] is an optional function that can be used to customize
/// the top app bar component.
/// [customBottomNavBar] is an optional function that can be used to customize
/// the bottom navigation bar component.
/// [height] represents the height of the top app bar.
const FrameLayout({ const FrameLayout({
required this.body, required this.body,
this.customAppBar, this.customAppBar,
@ -42,10 +37,17 @@ class FrameLayout extends StructuralLayout {
super.key, super.key,
}); });
/// An optional function that can be used to customize the top app bar
final TopAppBarComponent? Function(TopAppBarComponent?)? customAppBar; final TopAppBarComponent? Function(TopAppBarComponent?)? customAppBar;
/// An optional function that can be used to customize the bottom navigation
final BottomNavigationBarComponent? Function(BottomNavigationBarComponent?)? final BottomNavigationBarComponent? Function(BottomNavigationBarComponent?)?
customBottomNavBar; customBottomNavBar;
/// The main content of the layout.
final Widget body; final Widget body;
/// The height of the top app bar.
final double height; final double height;
@override @override

View File

@ -14,16 +14,11 @@
// 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/>.
/// This file contains the abstract class [TopBarLayout] and two concrete
/// classes [TopAppBarLayout] and [TopNavigationBarLayout].
/// The [TopBarLayout] abstract class defines a layout structure with a top bar.
/// The [TopAppBarLayout] and [TopNavigationBarLayout] classes are concrete
/// implementations of the [TopBarLayout] class.
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:wyatt_ui_components/wyatt_ui_components.dart'; import 'package:wyatt_ui_components/wyatt_ui_components.dart';
import 'package:wyatt_ui_layout/src/presentation/layouts/layout.dart'; import 'package:wyatt_ui_layout/src/presentation/layouts/layout.dart';
/// {@template top_bar_layout}
/// An abstract class for creating layouts with a top bar component. /// An abstract class for creating layouts with a top bar component.
/// ///
/// This class provides a base for creating layouts that include a top bar /// This class provides a base for creating layouts that include a top bar
@ -34,14 +29,10 @@ import 'package:wyatt_ui_layout/src/presentation/layouts/layout.dart';
/// given [BuildContext]. /// given [BuildContext].
/// ///
/// [T] represents the type of the top bar component. /// [T] represents the type of the top bar component.
/// {@endtemplate}
abstract class TopBarLayout<T extends TopBarComponent> abstract class TopBarLayout<T extends TopBarComponent>
extends StructuralLayout { extends StructuralLayout {
/// Creates a [TopBarLayout] instance. /// {@macro top_bar_layout}
///
/// [body] represents the main content of the layout.
/// [custom] is an optional function that can be used to customize
/// the top bar component.
/// [height] represents the height of the top bar.
const TopBarLayout({ const TopBarLayout({
required this.body, required this.body,
this.custom, this.custom,
@ -49,9 +40,15 @@ abstract class TopBarLayout<T extends TopBarComponent>
super.key, super.key,
}); });
/// The main content of the layout.
final Widget body; final Widget body;
/// An optional function that can be used to customize the top bar component.
/// The function takes the top bar component as an argument and returns
/// a customized top bar component.
final T? Function(T?)? custom; final T? Function(T?)? custom;
/// The height of the top bar.
final double height; final double height;
/// Returns the top bar component for the given [BuildContext]. /// Returns the top bar component for the given [BuildContext].

View File

@ -14,7 +14,7 @@
// 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/>.
/// Wyatt Ui Layout /// Wyatt UI Layout
library wyatt_ui_layout; library wyatt_ui_layout;
export 'src/src.dart'; export 'src/src.dart';

View File

@ -3,27 +3,22 @@ description: Main layouts to help you build your application views.
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_ui_layout repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_ui_layout
version: 0.0.1 version: 0.0.1
publish_to: "none" publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
environment: environment:
sdk: ">=2.17.0 <3.0.0" sdk: ">=2.17.0 <3.0.0"
dependencies: dependencies:
flutter: flutter: { sdk: flutter }
sdk: flutter
gap: ^2.0.1 gap: ^2.0.1
wyatt_ui_components: wyatt_ui_components:
git: hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
url: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages version: ^0.0.1
path: packages/wyatt_ui_components
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: { sdk: flutter }
sdk: flutter
wyatt_analysis: wyatt_analysis:
git: hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
url: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages version: ^2.4.1
ref: wyatt_analysis-v2.4.1
path: packages/wyatt_analysis