feat(bloc_layout): add grid content implementations

This commit is contained in:
2023-02-28 15:42:02 +00:00
committed by Gitea
parent abb5f0c735
commit 89ce553fa2
35 changed files with 364 additions and 32 deletions
@@ -0,0 +1,17 @@
// 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/>.
export './grid_layout.dart';
@@ -0,0 +1,76 @@
// 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/>.
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
class GridLayout extends StatelessWidget {
const GridLayout({
required this.children,
this.verticalGap = 30,
this.horizontalGap = 30,
super.key,
});
final List<Widget> children;
final double verticalGap;
final double horizontalGap;
@override
Widget build(BuildContext context) {
if (children.isEmpty) {
return const SizedBox.shrink();
}
final childrenLeft = <Widget>[];
final childrenRight = <Widget>[];
int i = 0;
for (final child in children) {
if (i.isEven) {
childrenLeft
..add(child)
..add(Gap(verticalGap));
} else {
childrenRight
..add(child)
..add(Gap(verticalGap));
}
i++;
}
return Column(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
children: childrenLeft,
),
),
Gap(horizontalGap),
Expanded(
child: Column(
children: childrenRight,
),
),
],
),
],
);
}
}
@@ -31,3 +31,11 @@ abstract class Layout extends StatelessWidget {
/// for the widget.
const Layout({super.key});
}
abstract class StructuralLayout extends Layout {
const StructuralLayout({super.key});
}
abstract class ContentLayout extends Layout {
const ContentLayout({super.key});
}
@@ -0,0 +1,18 @@
// 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/>.
export './content_layouts/content_layouts.dart';
export './structural_layouts/structural_layouts.dart';
@@ -29,7 +29,7 @@ import 'package:wyatt_ui_layout/src/presentation/layouts/layout.dart';
/// A concrete implementation of the [Layout] abstract class for a layout with
/// a bottom navigation bar component.
class BottomNavigationBarLayout extends Layout {
class BottomNavigationBarLayout extends StructuralLayout {
/// Creates a [BottomNavigationBarLayout] instance.
///
/// [body] represents the main content of the layout.
@@ -13,6 +13,7 @@
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:flutter/material.dart';
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
import 'package:wyatt_ui_layout/src/presentation/layouts/layout.dart';
@@ -24,7 +25,7 @@ import 'package:wyatt_ui_layout/src/presentation/layouts/layout.dart';
/// You can customize the app bar and the bottom navigation bar by passing
/// a [customAppBar] and a [customBottomNavBar] functions that take
/// the corresponding components and return the customized ones.
class FrameLayout extends Layout {
class FrameLayout extends StructuralLayout {
/// Creates a [FrameLayout] instance.
///
/// [body] represents the main content of the layout.
@@ -0,0 +1,19 @@
// 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/>.
export './bottom_navigation_bar_layout.dart';
export './frame_layout.dart';
export './top_app_bar_layout.dart';
@@ -34,7 +34,8 @@ import 'package:wyatt_ui_layout/src/presentation/layouts/layout.dart';
/// given [BuildContext].
///
/// [T] represents the type of the top bar component.
abstract class TopBarLayout<T extends TopBarComponent> extends Layout {
abstract class TopBarLayout<T extends TopBarComponent>
extends StructuralLayout {
/// Creates a [TopBarLayout] instance.
///
/// [body] represents the main content of the layout.
@@ -14,6 +14,4 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
export 'layouts/bottom_navigation_bar_layout.dart';
export 'layouts/frame_layout.dart';
export 'layouts/top_app_bar_layout.dart';
export './layouts/layouts.dart';
+1
View File
@@ -11,6 +11,7 @@ environment:
dependencies:
flutter:
sdk: flutter
gap: ^2.0.1
wyatt_ui_components:
git: