diff --git a/packages/wyatt_ui_layout/example/lib/components/custom_bottom_navigation_bar.g.dart b/packages/wyatt_ui_layout/example/lib/components/custom_bottom_navigation_bar.g.dart index fc15f676..2602e144 100644 --- a/packages/wyatt_ui_layout/example/lib/components/custom_bottom_navigation_bar.g.dart +++ b/packages/wyatt_ui_layout/example/lib/components/custom_bottom_navigation_bar.g.dart @@ -17,11 +17,15 @@ class $CustomBottomNavigationBarCWProxyImpl CustomBottomNavigationBar currentIndex(int? currentIndex) => this(currentIndex: currentIndex); @override + CustomBottomNavigationBar items(List? items) => + this(items: items); + @override CustomBottomNavigationBar key(Key? key) => this(key: key); @override CustomBottomNavigationBar call({ void Function(BuildContext, int)? onTap, int? currentIndex, + List? items, Key? key, }) => CustomBottomNavigationBar( diff --git a/packages/wyatt_ui_layout/example/lib/components/custom_desktop_app_bar.dart b/packages/wyatt_ui_layout/example/lib/components/custom_desktop_app_bar.dart new file mode 100644 index 00000000..d250eb2d --- /dev/null +++ b/packages/wyatt_ui_layout/example/lib/components/custom_desktop_app_bar.dart @@ -0,0 +1,21 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:wyatt_component_copy_with_extension/wyatt_component_copy_with_extension.dart'; +import 'package:wyatt_ui_components/wyatt_ui_components.dart'; + +part 'custom_desktop_app_bar.g.dart'; + +@ComponentCopyWithExtension() +class CustomDesktopAppBar extends TopAppBarComponent + with $CustomDesktopAppBarCWMixin { + const CustomDesktopAppBar({ + super.title, + super.key, + }); + + @override + Widget build(BuildContext context) => AppBar( + backgroundColor: Colors.green, + title: Text(title?.data ?? ''), + ); +} diff --git a/packages/wyatt_ui_layout/example/lib/components/custom_desktop_app_bar.g.dart b/packages/wyatt_ui_layout/example/lib/components/custom_desktop_app_bar.g.dart new file mode 100644 index 00000000..809792c0 --- /dev/null +++ b/packages/wyatt_ui_layout/example/lib/components/custom_desktop_app_bar.g.dart @@ -0,0 +1,104 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'custom_desktop_app_bar.dart'; + +// ************************************************************************** +// ComponentCopyWithGenerator +// ************************************************************************** + +class $CustomDesktopAppBarCWProxyImpl implements $TopAppBarComponentCWProxy { + const $CustomDesktopAppBarCWProxyImpl(this._value); + final CustomDesktopAppBar _value; + @override + CustomDesktopAppBar title(TextWrapper? title) => this(title: title); + @override + CustomDesktopAppBar centerTitle(bool? centerTitle) => + this(centerTitle: centerTitle); + @override + CustomDesktopAppBar shape(ShapeBorder? shape) => this(shape: shape); + @override + CustomDesktopAppBar systemOverlayStyle( + SystemUiOverlayStyle? systemOverlayStyle) => + this(systemOverlayStyle: systemOverlayStyle); + @override + CustomDesktopAppBar automaticallyImplyLeading( + bool? automaticallyImplyLeading) => + this(automaticallyImplyLeading: automaticallyImplyLeading); + @override + CustomDesktopAppBar flexibleSpace(Widget? flexibleSpace) => + this(flexibleSpace: flexibleSpace); + @override + CustomDesktopAppBar bottom(PreferredSizeWidget? bottom) => + this(bottom: bottom); + @override + CustomDesktopAppBar elevation(double? elevation) => + this(elevation: elevation); + @override + CustomDesktopAppBar scrolledUnderElevation(double? scrolledUnderElevation) => + this(scrolledUnderElevation: scrolledUnderElevation); + @override + CustomDesktopAppBar shadowColor(Color? shadowColor) => + this(shadowColor: shadowColor); + @override + CustomDesktopAppBar surfaceTintColor(Color? surfaceTintColor) => + this(surfaceTintColor: surfaceTintColor); + @override + CustomDesktopAppBar backgroundColor(MultiColor? backgroundColor) => + this(backgroundColor: backgroundColor); + @override + CustomDesktopAppBar iconTheme(IconThemeData? iconTheme) => + this(iconTheme: iconTheme); + @override + CustomDesktopAppBar primary(bool? primary) => this(primary: primary); + @override + CustomDesktopAppBar excludeHeaderSemantics(bool? excludeHeaderSemantics) => + this(excludeHeaderSemantics: excludeHeaderSemantics); + @override + CustomDesktopAppBar toolbarHeight(double? toolbarHeight) => + this(toolbarHeight: toolbarHeight); + @override + CustomDesktopAppBar leadingWidth(double? leadingWidth) => + this(leadingWidth: leadingWidth); + @override + CustomDesktopAppBar leading(Widget? leading) => this(leading: leading); + @override + CustomDesktopAppBar actions(List? actions) => this(actions: actions); + @override + CustomDesktopAppBar expandedWidget(List? expandedWidget) => + this(expandedWidget: expandedWidget); + @override + CustomDesktopAppBar key(Key? key) => this(key: key); + @override + CustomDesktopAppBar call({ + TextWrapper? title, + bool? centerTitle, + ShapeBorder? shape, + SystemUiOverlayStyle? systemOverlayStyle, + bool? automaticallyImplyLeading, + Widget? flexibleSpace, + PreferredSizeWidget? bottom, + double? elevation, + double? scrolledUnderElevation, + Color? shadowColor, + Color? surfaceTintColor, + MultiColor? backgroundColor, + IconThemeData? iconTheme, + bool? primary, + bool? excludeHeaderSemantics, + double? toolbarHeight, + double? leadingWidth, + Widget? leading, + List? actions, + List? expandedWidget, + Key? key, + }) => + CustomDesktopAppBar( + title: title ?? _value.title, + key: key ?? _value.key, + ); +} + +mixin $CustomDesktopAppBarCWMixin on Component { + $TopAppBarComponentCWProxy get copyWith => + $CustomDesktopAppBarCWProxyImpl(this as CustomDesktopAppBar); +} diff --git a/packages/wyatt_ui_layout/example/lib/components/custom_app_bar.dart b/packages/wyatt_ui_layout/example/lib/components/custom_mobile_app_bar.dart similarity index 68% rename from packages/wyatt_ui_layout/example/lib/components/custom_app_bar.dart rename to packages/wyatt_ui_layout/example/lib/components/custom_mobile_app_bar.dart index 9c7da189..bac09e22 100644 --- a/packages/wyatt_ui_layout/example/lib/components/custom_app_bar.dart +++ b/packages/wyatt_ui_layout/example/lib/components/custom_mobile_app_bar.dart @@ -3,17 +3,19 @@ import 'package:flutter/services.dart'; import 'package:wyatt_component_copy_with_extension/wyatt_component_copy_with_extension.dart'; import 'package:wyatt_ui_components/wyatt_ui_components.dart'; -part 'custom_app_bar.g.dart'; +part 'custom_mobile_app_bar.g.dart'; @ComponentCopyWithExtension() -class CustomAppBar extends TopAppBarComponent with $CustomAppBarCWMixin { - const CustomAppBar({ +class CustomMobileAppBar extends TopAppBarComponent + with $CustomMobileAppBarCWMixin { + const CustomMobileAppBar({ super.title, super.key, }); @override Widget build(BuildContext context) => AppBar( + backgroundColor: Colors.red, title: Text(title?.data ?? ''), ); } diff --git a/packages/wyatt_ui_layout/example/lib/components/custom_mobile_app_bar.g.dart b/packages/wyatt_ui_layout/example/lib/components/custom_mobile_app_bar.g.dart new file mode 100644 index 00000000..f825797a --- /dev/null +++ b/packages/wyatt_ui_layout/example/lib/components/custom_mobile_app_bar.g.dart @@ -0,0 +1,103 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'custom_mobile_app_bar.dart'; + +// ************************************************************************** +// ComponentCopyWithGenerator +// ************************************************************************** + +class $CustomMobileAppBarCWProxyImpl implements $TopAppBarComponentCWProxy { + const $CustomMobileAppBarCWProxyImpl(this._value); + final CustomMobileAppBar _value; + @override + CustomMobileAppBar title(TextWrapper? title) => this(title: title); + @override + CustomMobileAppBar centerTitle(bool? centerTitle) => + this(centerTitle: centerTitle); + @override + CustomMobileAppBar shape(ShapeBorder? shape) => this(shape: shape); + @override + CustomMobileAppBar systemOverlayStyle( + SystemUiOverlayStyle? systemOverlayStyle) => + this(systemOverlayStyle: systemOverlayStyle); + @override + CustomMobileAppBar automaticallyImplyLeading( + bool? automaticallyImplyLeading) => + this(automaticallyImplyLeading: automaticallyImplyLeading); + @override + CustomMobileAppBar flexibleSpace(Widget? flexibleSpace) => + this(flexibleSpace: flexibleSpace); + @override + CustomMobileAppBar bottom(PreferredSizeWidget? bottom) => + this(bottom: bottom); + @override + CustomMobileAppBar elevation(double? elevation) => this(elevation: elevation); + @override + CustomMobileAppBar scrolledUnderElevation(double? scrolledUnderElevation) => + this(scrolledUnderElevation: scrolledUnderElevation); + @override + CustomMobileAppBar shadowColor(Color? shadowColor) => + this(shadowColor: shadowColor); + @override + CustomMobileAppBar surfaceTintColor(Color? surfaceTintColor) => + this(surfaceTintColor: surfaceTintColor); + @override + CustomMobileAppBar backgroundColor(MultiColor? backgroundColor) => + this(backgroundColor: backgroundColor); + @override + CustomMobileAppBar iconTheme(IconThemeData? iconTheme) => + this(iconTheme: iconTheme); + @override + CustomMobileAppBar primary(bool? primary) => this(primary: primary); + @override + CustomMobileAppBar excludeHeaderSemantics(bool? excludeHeaderSemantics) => + this(excludeHeaderSemantics: excludeHeaderSemantics); + @override + CustomMobileAppBar toolbarHeight(double? toolbarHeight) => + this(toolbarHeight: toolbarHeight); + @override + CustomMobileAppBar leadingWidth(double? leadingWidth) => + this(leadingWidth: leadingWidth); + @override + CustomMobileAppBar leading(Widget? leading) => this(leading: leading); + @override + CustomMobileAppBar actions(List? actions) => this(actions: actions); + @override + CustomMobileAppBar expandedWidget(List? expandedWidget) => + this(expandedWidget: expandedWidget); + @override + CustomMobileAppBar key(Key? key) => this(key: key); + @override + CustomMobileAppBar call({ + TextWrapper? title, + bool? centerTitle, + ShapeBorder? shape, + SystemUiOverlayStyle? systemOverlayStyle, + bool? automaticallyImplyLeading, + Widget? flexibleSpace, + PreferredSizeWidget? bottom, + double? elevation, + double? scrolledUnderElevation, + Color? shadowColor, + Color? surfaceTintColor, + MultiColor? backgroundColor, + IconThemeData? iconTheme, + bool? primary, + bool? excludeHeaderSemantics, + double? toolbarHeight, + double? leadingWidth, + Widget? leading, + List? actions, + List? expandedWidget, + Key? key, + }) => + CustomMobileAppBar( + title: title ?? _value.title, + key: key ?? _value.key, + ); +} + +mixin $CustomMobileAppBarCWMixin on Component { + $TopAppBarComponentCWProxy get copyWith => + $CustomMobileAppBarCWProxyImpl(this as CustomMobileAppBar); +} diff --git a/packages/wyatt_ui_layout/example/lib/core/app_theme_component.dart b/packages/wyatt_ui_layout/example/lib/core/app_theme_component.dart index 3df937d1..a4cb8695 100644 --- a/packages/wyatt_ui_layout/example/lib/core/app_theme_component.dart +++ b/packages/wyatt_ui_layout/example/lib/core/app_theme_component.dart @@ -1,14 +1,18 @@ import 'package:flutter/material.dart'; import 'package:wyatt_ui_components/wyatt_ui_components.dart'; -import 'package:wyatt_ui_layout_example/components/custom_app_bar.dart'; import 'package:wyatt_ui_layout_example/components/custom_bottom_navigation_bar.dart'; +import 'package:wyatt_ui_layout_example/components/custom_desktop_app_bar.dart'; +import 'package:wyatt_ui_layout_example/components/custom_mobile_app_bar.dart'; import 'package:wyatt_ui_layout_example/pages/bottom_navigation_bar_layout_page_1.dart'; import 'package:wyatt_ui_layout_example/pages/bottom_navigation_bar_layout_page_2.dart'; class AppThemeComponent { static ComponentThemeData get components => ComponentThemeData.raw( - topAppBar: const CustomAppBar(), - bottomNavigationBar: CustomBottomNavigationBar( + topAppBars: { + 'mobile': const CustomMobileAppBar(), + 'desktop': const CustomDesktopAppBar(), + }.registry(), + bottomNavigationBars: CustomBottomNavigationBar( onTap: (context, index) { switch (index) { case 0: @@ -37,6 +41,6 @@ class AppThemeComponent { break; } }, - ), + ).registry(), ); } diff --git a/packages/wyatt_ui_layout/example/lib/pages/app_bar_layout_page.dart b/packages/wyatt_ui_layout/example/lib/pages/app_bar_layout_page.dart index 4b3177e2..cfbb747d 100644 --- a/packages/wyatt_ui_layout/example/lib/pages/app_bar_layout_page.dart +++ b/packages/wyatt_ui_layout/example/lib/pages/app_bar_layout_page.dart @@ -6,12 +6,15 @@ class AppBarLayoutPage extends StatelessWidget { const AppBarLayoutPage({super.key}); @override - Widget build(BuildContext context) => TopAppBarLayout( - custom: (topBar) => - topBar?.copyWith.title(const TextWrapper('New Title')), - body: const Center( - child: Text( - 'Body', + Widget build(BuildContext context) => LayoutBuilder( + builder: (context, constraint) => StructuralLayout.withTopAppBar( + barId: constraint.maxWidth < 600 ? 'mobile' : 'desktop', + custom: (topBar) => + topBar?.copyWith.title(const TextWrapper('New Title')), + body: const Center( + child: Text( + 'Body', + ), ), ), ); diff --git a/packages/wyatt_ui_layout/example/lib/pages/bottom_navigation_bar_layout_page_1.dart b/packages/wyatt_ui_layout/example/lib/pages/bottom_navigation_bar_layout_page_1.dart index 84c3d95d..0ffd8ea4 100644 --- a/packages/wyatt_ui_layout/example/lib/pages/bottom_navigation_bar_layout_page_1.dart +++ b/packages/wyatt_ui_layout/example/lib/pages/bottom_navigation_bar_layout_page_1.dart @@ -5,7 +5,7 @@ class BottomNavigationBarLayoutPage1 extends StatelessWidget { const BottomNavigationBarLayoutPage1({super.key}); @override - Widget build(BuildContext context) => BottomNavigationBarLayout( + Widget build(BuildContext context) => StructuralLayout.withBottomNavBar( custom: (p0) => p0?.copyWith.call(currentIndex: 0), body: const TopAppBarLayout( body: Center( diff --git a/packages/wyatt_ui_layout/example/lib/pages/bottom_navigation_bar_layout_page_2.dart b/packages/wyatt_ui_layout/example/lib/pages/bottom_navigation_bar_layout_page_2.dart index fbd6b13a..ae4d9880 100644 --- a/packages/wyatt_ui_layout/example/lib/pages/bottom_navigation_bar_layout_page_2.dart +++ b/packages/wyatt_ui_layout/example/lib/pages/bottom_navigation_bar_layout_page_2.dart @@ -5,7 +5,7 @@ class BottomNavigationBarLayoutPage2 extends StatelessWidget { const BottomNavigationBarLayoutPage2({super.key}); @override - Widget build(BuildContext context) => BottomNavigationBarLayout( + Widget build(BuildContext context) => StructuralLayout.withBottomNavBar( custom: (p0) => p0?.copyWith.currentIndex(1), body: const TopAppBarLayout( body: Center( diff --git a/packages/wyatt_ui_layout/example/macos/Flutter/ephemeral/Flutter-Generated.xcconfig b/packages/wyatt_ui_layout/example/macos/Flutter/ephemeral/Flutter-Generated.xcconfig index a59a9b7e..80a67b61 100644 --- a/packages/wyatt_ui_layout/example/macos/Flutter/ephemeral/Flutter-Generated.xcconfig +++ b/packages/wyatt_ui_layout/example/macos/Flutter/ephemeral/Flutter-Generated.xcconfig @@ -2,10 +2,12 @@ FLUTTER_ROOT=/Users/maloleon/Library/flutter FLUTTER_APPLICATION_PATH=/Users/maloleon/Studio/wyatt-packages/packages/wyatt_ui_layout/example COCOAPODS_PARALLEL_CODE_SIGN=true +FLUTTER_TARGET=/Users/maloleon/Studio/wyatt-packages/packages/wyatt_ui_layout/example/lib/main.dart FLUTTER_BUILD_DIR=build FLUTTER_BUILD_NAME=1.0.0 FLUTTER_BUILD_NUMBER=1 +DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==,RkxVVFRFUl9XRUJfQ0FOVkFTS0lUX1VSTD1odHRwczovL3d3dy5nc3RhdGljLmNvbS9mbHV0dGVyLWNhbnZhc2tpdC9iMjAxODNlMDQwOTYwOTRiY2MzN2Q5Y2RlMmE0Yjk2ZjVjYzY4NGNmLw== DART_OBFUSCATION=false TRACK_WIDGET_CREATION=true TREE_SHAKE_ICONS=false -PACKAGE_CONFIG=.dart_tool/package_config.json +PACKAGE_CONFIG=/Users/maloleon/Studio/wyatt-packages/packages/wyatt_ui_layout/example/.dart_tool/package_config.json diff --git a/packages/wyatt_ui_layout/example/macos/Flutter/ephemeral/flutter_export_environment.sh b/packages/wyatt_ui_layout/example/macos/Flutter/ephemeral/flutter_export_environment.sh index 4883d2d9..51db70ad 100755 --- a/packages/wyatt_ui_layout/example/macos/Flutter/ephemeral/flutter_export_environment.sh +++ b/packages/wyatt_ui_layout/example/macos/Flutter/ephemeral/flutter_export_environment.sh @@ -3,10 +3,12 @@ export "FLUTTER_ROOT=/Users/maloleon/Library/flutter" export "FLUTTER_APPLICATION_PATH=/Users/maloleon/Studio/wyatt-packages/packages/wyatt_ui_layout/example" export "COCOAPODS_PARALLEL_CODE_SIGN=true" +export "FLUTTER_TARGET=/Users/maloleon/Studio/wyatt-packages/packages/wyatt_ui_layout/example/lib/main.dart" export "FLUTTER_BUILD_DIR=build" export "FLUTTER_BUILD_NAME=1.0.0" export "FLUTTER_BUILD_NUMBER=1" +export "DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==,RkxVVFRFUl9XRUJfQ0FOVkFTS0lUX1VSTD1odHRwczovL3d3dy5nc3RhdGljLmNvbS9mbHV0dGVyLWNhbnZhc2tpdC9iMjAxODNlMDQwOTYwOTRiY2MzN2Q5Y2RlMmE0Yjk2ZjVjYzY4NGNmLw==" export "DART_OBFUSCATION=false" export "TRACK_WIDGET_CREATION=true" export "TREE_SHAKE_ICONS=false" -export "PACKAGE_CONFIG=.dart_tool/package_config.json" +export "PACKAGE_CONFIG=/Users/maloleon/Studio/wyatt-packages/packages/wyatt_ui_layout/example/.dart_tool/package_config.json" diff --git a/packages/wyatt_ui_layout/example/macos/Runner.xcodeproj/project.pbxproj b/packages/wyatt_ui_layout/example/macos/Runner.xcodeproj/project.pbxproj index d9333e47..c5fd5489 100644 --- a/packages/wyatt_ui_layout/example/macos/Runner.xcodeproj/project.pbxproj +++ b/packages/wyatt_ui_layout/example/macos/Runner.xcodeproj/project.pbxproj @@ -182,7 +182,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = ""; TargetAttributes = { 33CC10EC2044A3C60003C045 = { diff --git a/packages/wyatt_ui_layout/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/wyatt_ui_layout/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index fb7259e1..83d88728 100644 --- a/packages/wyatt_ui_layout/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/wyatt_ui_layout/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ =2.17.0 <3.0.0" + sdk: ">=3.0.0 <4.0.0" # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions diff --git a/packages/wyatt_ui_layout/lib/src/presentation/layouts/content_layouts/content_layout.dart b/packages/wyatt_ui_layout/lib/src/presentation/layouts/content_layouts/content_layout.dart new file mode 100644 index 00000000..f2f88eba --- /dev/null +++ b/packages/wyatt_ui_layout/lib/src/presentation/layouts/content_layouts/content_layout.dart @@ -0,0 +1,39 @@ +// 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 . + +import 'package:flutter/material.dart'; +import 'package:wyatt_ui_layout/src/presentation/layouts/layout.dart'; +import 'package:wyatt_ui_layout/wyatt_ui_layout.dart'; + +/// {@template content_layout} +/// An abstract class that provides a base for creating custom content layout +/// widgets. +/// {@endtemplate} +abstract class ContentLayout extends Layout { + /// {@macro content_layout} + const ContentLayout({super.key}); + + factory ContentLayout.withGrid({ + required List children, + double verticalGap = 30, + double horizontalGap = 30, + }) => + GridLayout( + verticalGap: verticalGap, + horizontalGap: horizontalGap, + children: children, + ); +} diff --git a/packages/wyatt_ui_layout/lib/src/presentation/layouts/content_layouts/content_layouts.dart b/packages/wyatt_ui_layout/lib/src/presentation/layouts/content_layouts/content_layouts.dart index e5215b69..6d33cfcd 100644 --- a/packages/wyatt_ui_layout/lib/src/presentation/layouts/content_layouts/content_layouts.dart +++ b/packages/wyatt_ui_layout/lib/src/presentation/layouts/content_layouts/content_layouts.dart @@ -14,4 +14,5 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +export './content_layout.dart'; export './grid_layout.dart'; diff --git a/packages/wyatt_ui_layout/lib/src/presentation/layouts/content_layouts/grid_layout.dart b/packages/wyatt_ui_layout/lib/src/presentation/layouts/content_layouts/grid_layout.dart index 04c9a7a0..86d4b0ef 100644 --- a/packages/wyatt_ui_layout/lib/src/presentation/layouts/content_layouts/grid_layout.dart +++ b/packages/wyatt_ui_layout/lib/src/presentation/layouts/content_layouts/grid_layout.dart @@ -16,7 +16,7 @@ import 'package:flutter/material.dart'; import 'package:gap/gap.dart'; -import 'package:wyatt_ui_layout/src/presentation/layouts/layout.dart'; +import 'package:wyatt_ui_layout/src/presentation/layouts/content_layouts/content_layout.dart'; /// {@template grid_layout} /// A concrete implementation of the [ContentLayout] abstract class for a layout diff --git a/packages/wyatt_ui_layout/lib/src/presentation/layouts/layout.dart b/packages/wyatt_ui_layout/lib/src/presentation/layouts/layout.dart index 28068913..fd618d81 100644 --- a/packages/wyatt_ui_layout/lib/src/presentation/layouts/layout.dart +++ b/packages/wyatt_ui_layout/lib/src/presentation/layouts/layout.dart @@ -28,21 +28,3 @@ abstract class Layout extends StatelessWidget { /// {@macro layout} 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 { - /// {@macro structural_layout} - 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 { - /// {@macro content_layout} - const ContentLayout({super.key}); -} diff --git a/packages/wyatt_ui_layout/lib/src/presentation/layouts/structural_layouts/bottom_navigation_bar_layout.dart b/packages/wyatt_ui_layout/lib/src/presentation/layouts/structural_layouts/bottom_navigation_bar_layout.dart index 3c72ffcf..8746fc0c 100644 --- a/packages/wyatt_ui_layout/lib/src/presentation/layouts/structural_layouts/bottom_navigation_bar_layout.dart +++ b/packages/wyatt_ui_layout/lib/src/presentation/layouts/structural_layouts/bottom_navigation_bar_layout.dart @@ -19,6 +19,7 @@ import 'package:flutter/material.dart'; import 'package:wyatt_ui_components/wyatt_ui_components.dart'; import 'package:wyatt_ui_layout/src/core/scaffold_fields_wrapper.dart'; import 'package:wyatt_ui_layout/src/presentation/layouts/layout.dart'; +import 'package:wyatt_ui_layout/src/presentation/layouts/structural_layouts/structural_layout.dart'; /// {@template bottom_navigation_bar_layout} /// A concrete implementation of the [Layout] abstract class for a layout which @@ -29,6 +30,7 @@ class BottomNavigationBarLayout extends StructuralLayout { const BottomNavigationBarLayout({ required this.body, this.custom, + this.barId, this.scaffoldFieldsWrapper, super.key, }); @@ -41,15 +43,23 @@ class BottomNavigationBarLayout extends StructuralLayout { final BottomNavigationBarComponent? Function(BottomNavigationBarComponent?)? custom; + /// The parameter [barId] enables to specify the particular + /// bottom bar to utilize. + final String? barId; + + /// The [scaffoldFieldsWrapper] is a final variable that serves as a wrapper + /// for customizing the scaffold. + /// It allows for tailored modifications and enhancements to the standard + /// scaffold functionality. final ScaffoldFieldsWrapper? scaffoldFieldsWrapper; @override Widget build(BuildContext context) => Scaffold( body: body, bottomNavigationBar: custom?.call( - context.components.bottomNavigationBar, + context.components.bottomNavigationBarComponent(barId).call(), ) ?? - context.components.bottomNavigationBar, + context.components.bottomNavigationBarComponent(barId).call(), floatingActionButtonLocation: scaffoldFieldsWrapper?.floatingActionButtonLocation, floatingActionButtonAnimator: diff --git a/packages/wyatt_ui_layout/lib/src/presentation/layouts/structural_layouts/frame_layout.dart b/packages/wyatt_ui_layout/lib/src/presentation/layouts/structural_layouts/frame_layout.dart index e44a8163..5b1a8879 100644 --- a/packages/wyatt_ui_layout/lib/src/presentation/layouts/structural_layouts/frame_layout.dart +++ b/packages/wyatt_ui_layout/lib/src/presentation/layouts/structural_layouts/frame_layout.dart @@ -18,7 +18,7 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:wyatt_ui_components/wyatt_ui_components.dart'; import 'package:wyatt_ui_layout/src/core/scaffold_fields_wrapper.dart'; -import 'package:wyatt_ui_layout/src/presentation/layouts/layout.dart'; +import 'package:wyatt_ui_layout/src/presentation/layouts/structural_layouts/structural_layout.dart'; /// {@template frame_layout} /// A layout that contains a top app bar, a body and a bottom navigation bar. @@ -36,6 +36,9 @@ class FrameLayout extends StructuralLayout { this.customAppBar, this.customBottomNavBar, this.customFloatingActionButton, + this.appBarId, + this.bottomNavBarId, + this.floatingActionButtonId, this.height = 60, this.scaffoldFieldsWrapper, super.key, @@ -53,6 +56,18 @@ class FrameLayout extends StructuralLayout { final FloatingActionButtonComponent? Function(FloatingActionButtonComponent?)? customFloatingActionButton; + /// The parameter [appBarId] enables to specify the particular + /// app bar to utilize. + final String? appBarId; + + /// The parameter [bottomNavBarId] enables to specify the particular + /// bottom bar to utilize. + final String? bottomNavBarId; + + /// The parameter [floatingActionButtonId] enables to specify + /// the particular floating action button to utilize. + final String? floatingActionButtonId; + /// The main content of the layout. final Widget body; @@ -63,20 +78,27 @@ class FrameLayout extends StructuralLayout { @override Widget build(BuildContext context) => Scaffold( - appBar: (customAppBar?.call(context.components.topAppBar) != null || - context.components.topAppBar != null) + appBar: (customAppBar + ?.call(context.components.topAppBarComponent(appBarId)()) != + null) ? PreferredSize( preferredSize: Size.fromHeight(height), - child: customAppBar?.call(context.components.topAppBar) ?? - context.components.topAppBar!, + child: customAppBar?.call( + context.components.topAppBarComponent(appBarId)(), + ) ?? + context.components.topAppBarComponent(appBarId)(), ) : null, - floatingActionButton: customFloatingActionButton - ?.call(context.components.floatingActionButton) ?? - context.components.floatingActionButton, - bottomNavigationBar: - customBottomNavBar?.call(context.components.bottomNavigationBar) ?? - context.components.bottomNavigationBar, + floatingActionButton: customFloatingActionButton?.call( + context.components + .floatingActionButtonComponent(floatingActionButtonId)(), + ) ?? + context.components + .floatingActionButtonComponent(floatingActionButtonId)(), + bottomNavigationBar: customBottomNavBar?.call( + context.components.bottomNavigationBarComponent(bottomNavBarId)(), + ) ?? + context.components.bottomNavigationBarComponent(bottomNavBarId)(), body: body, floatingActionButtonLocation: scaffoldFieldsWrapper?.floatingActionButtonLocation, diff --git a/packages/wyatt_ui_layout/lib/src/presentation/layouts/structural_layouts/structural_layout.dart b/packages/wyatt_ui_layout/lib/src/presentation/layouts/structural_layouts/structural_layout.dart new file mode 100644 index 00000000..78bcdde9 --- /dev/null +++ b/packages/wyatt_ui_layout/lib/src/presentation/layouts/structural_layouts/structural_layout.dart @@ -0,0 +1,99 @@ +// 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 . + +import 'package:flutter/widgets.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/wyatt_ui_layout.dart'; + +typedef ComponentCallBack = T? Function(T? component); + +/// {@template structural_layout} +/// An abstract class that provides a base for creating custom structural layout +/// widgets. +/// {@endtemplate} +abstract class StructuralLayout extends Layout { + /// {@macro structural_layout} + const StructuralLayout({super.key}); + + factory StructuralLayout.withTopAppBar({ + required Widget body, + ComponentCallBack? custom, + String? barId, + double height = 60, + ScaffoldFieldsWrapper? scaffoldFieldsWrapper, + }) => + TopAppBarLayout( + body: body, + barId: barId, + custom: custom, + height: height, + scaffoldFieldsWrapper: scaffoldFieldsWrapper, + ); + + factory StructuralLayout.withTopNavigationBar({ + required Widget body, + ComponentCallBack? custom, + String? barId, + double height = 60, + ScaffoldFieldsWrapper? scaffoldFieldsWrapper, + }) => + TopNavigationBarLayout( + body: body, + barId: barId, + custom: custom, + height: height, + scaffoldFieldsWrapper: scaffoldFieldsWrapper, + ); + + factory StructuralLayout.withFrame({ + required Widget body, + ComponentCallBack? customAppBar, + ComponentCallBack? customBottomNavBar, + ComponentCallBack? + customFloatingActionButton, + String? appBarId, + String? bottomNavBarId, + String? floatingActionButtonId, + double height = 60, + ScaffoldFieldsWrapper? scaffoldFieldsWrapper, + }) => + FrameLayout( + body: body, + customAppBar: customAppBar, + customBottomNavBar: customBottomNavBar, + customFloatingActionButton: customFloatingActionButton, + appBarId: appBarId, + bottomNavBarId: bottomNavBarId, + floatingActionButtonId: floatingActionButtonId, + height: height, + scaffoldFieldsWrapper: scaffoldFieldsWrapper, + ); + + factory StructuralLayout.withBottomNavBar({ + required Widget? body, + BottomNavigationBarComponent? Function(BottomNavigationBarComponent?)? + custom, + String? barId, + ScaffoldFieldsWrapper? scaffoldFieldsWrapper, + }) => + BottomNavigationBarLayout( + body: body, + custom: custom, + barId: barId, + scaffoldFieldsWrapper: scaffoldFieldsWrapper, + ); +} diff --git a/packages/wyatt_ui_layout/lib/src/presentation/layouts/structural_layouts/structural_layouts.dart b/packages/wyatt_ui_layout/lib/src/presentation/layouts/structural_layouts/structural_layouts.dart index e22f407c..9ac4e11f 100644 --- a/packages/wyatt_ui_layout/lib/src/presentation/layouts/structural_layouts/structural_layouts.dart +++ b/packages/wyatt_ui_layout/lib/src/presentation/layouts/structural_layouts/structural_layouts.dart @@ -16,4 +16,5 @@ export './bottom_navigation_bar_layout.dart'; export './frame_layout.dart'; +export './structural_layout.dart'; export './top_app_bar_layout.dart'; diff --git a/packages/wyatt_ui_layout/lib/src/presentation/layouts/structural_layouts/top_app_bar_layout.dart b/packages/wyatt_ui_layout/lib/src/presentation/layouts/structural_layouts/top_app_bar_layout.dart index 0f9acc41..89322fa7 100644 --- a/packages/wyatt_ui_layout/lib/src/presentation/layouts/structural_layouts/top_app_bar_layout.dart +++ b/packages/wyatt_ui_layout/lib/src/presentation/layouts/structural_layouts/top_app_bar_layout.dart @@ -18,7 +18,7 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:wyatt_ui_components/wyatt_ui_components.dart'; import 'package:wyatt_ui_layout/src/core/scaffold_fields_wrapper.dart'; -import 'package:wyatt_ui_layout/src/presentation/layouts/layout.dart'; +import 'package:wyatt_ui_layout/src/presentation/layouts/structural_layouts/structural_layout.dart'; /// {@template top_bar_layout} /// An abstract class for creating layouts with a top bar component. @@ -27,7 +27,7 @@ import 'package:wyatt_ui_layout/src/presentation/layouts/layout.dart'; /// component, such as an app bar or navigation bar. /// /// Implementations of this class must provide a concrete implementation of -/// the [child] method, which returns the specific top bar component for the +/// the [appBar] method, which returns the specific top bar component for the /// given [BuildContext]. /// /// [T] represents the type of the top bar component. @@ -38,6 +38,7 @@ abstract class TopBarLayout const TopBarLayout({ required this.body, this.custom, + this.barId, this.height = 60, this.scaffoldFieldsWrapper, super.key, @@ -51,20 +52,31 @@ abstract class TopBarLayout /// a customized top bar component. final T? Function(T?)? custom; + /// The parameter [barId] enables to specify the particular app bar to use. + final String? barId; + /// The height of the top bar. final double height; /// Returns the top bar component for the given [BuildContext]. - T? child(BuildContext context); + T appBar(BuildContext context, String? barId); + /// The [scaffoldFieldsWrapper] is a final variable that serves as a wrapper + /// for customizing the scaffold. + /// It allows for tailored modifications and enhancements to the standard + /// scaffold functionality. final ScaffoldFieldsWrapper? scaffoldFieldsWrapper; @override Widget build(BuildContext context) => Scaffold( - appBar: (custom?.call(child(context)) != null || child(context) != null) + appBar: (custom?.call( + appBar(context, barId), + ) != + null) ? PreferredSize( preferredSize: Size.fromHeight(height), - child: custom?.call(child(context)) ?? child(context)!, + child: custom?.call(appBar(context, barId)) ?? + appBar(context, barId), ) : null, body: body, @@ -111,14 +123,16 @@ class TopAppBarLayout extends TopBarLayout { /// [height] represents the height of the top bar. const TopAppBarLayout({ required super.body, + super.barId, super.custom, super.height, + super.scaffoldFieldsWrapper, super.key, }); @override - TopAppBarComponent? child(BuildContext context) => - context.components.topAppBar; + TopAppBarComponent appBar(BuildContext context, String? barId) => + context.components.topAppBarComponent(barId).call(); } /// A concrete implementation of [TopBarLayout] for a navigation bar. @@ -131,12 +145,14 @@ class TopNavigationBarLayout extends TopBarLayout { /// [height] represents the height of the top bar. const TopNavigationBarLayout({ required super.body, + super.barId, super.custom, super.height, + super.scaffoldFieldsWrapper, super.key, }); @override - TopNavigationBarComponent? child(BuildContext context) => - context.components.topNavigationBar; + TopNavigationBarComponent appBar(BuildContext context, String? barId) => + context.components.topNavigationBarComponent(barId).call(); } diff --git a/packages/wyatt_ui_layout/pubspec.yaml b/packages/wyatt_ui_layout/pubspec.yaml index 3c737053..4f01b1ea 100644 --- a/packages/wyatt_ui_layout/pubspec.yaml +++ b/packages/wyatt_ui_layout/pubspec.yaml @@ -6,7 +6,7 @@ version: 0.1.1 publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub environment: - sdk: ">=2.17.0 <3.0.0" + sdk: ">=3.0.0 <4.0.0" dependencies: flutter: { sdk: flutter }