feat(ui_layout): add new package for app compenant and start implementing layouts

This commit is contained in:
AN12345
2022-12-07 02:38:14 +00:00
committed by Gitea
parent 7fcb9e8ac3
commit 771f600eb7
93 changed files with 3055 additions and 0 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 'extensions/build_context_extensions.dart';
@@ -0,0 +1,23 @@
// 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:wyatt_wyatt_ui_layout/src/features/component_theme.dart';
import 'package:wyatt_wyatt_ui_layout/src/features/component_theme_data.dart';
extension ThemeComponentBuildContext on BuildContext {
ComponentThemeData get components => ComponentTheme.of(this);
}
@@ -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 'entities/components.dart';
@@ -0,0 +1,43 @@
// 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';
abstract class AppBarComponent extends PreferredSize {
final String? title;
const AppBarComponent({this.title, super.key})
: super(
preferredSize: const Size.fromHeight(60),
child: const SizedBox.shrink(),
);
AppBarComponent configure({String? title});
}
abstract class BottomNavigationBarComponent extends StatelessWidget {
final int currentIndex;
final void Function(BuildContext, int)? onTap;
const BottomNavigationBarComponent({
this.onTap,
this.currentIndex = 0,
super.key,
});
BottomNavigationBarComponent configure({
void Function(BuildContext, int)? onTap,
int currentIndex = 0,
});
}
@@ -0,0 +1,58 @@
// 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:wyatt_wyatt_ui_layout/src/features/component_theme_data.dart';
class ComponentTheme extends StatelessWidget {
final Widget child;
final ComponentThemeData themDataWidget;
const ComponentTheme({
required this.child,
required this.themDataWidget,
super.key,
});
static ComponentThemeData of(BuildContext context) {
final _InheritedComponentTheme? inheritedThemeComponent =
context.dependOnInheritedWidgetOfExactType<_InheritedComponentTheme>();
assert(
inheritedThemeComponent != null,
'Theme component not find in tree',
);
return inheritedThemeComponent!.themeWidget.themDataWidget;
}
@override
Widget build(BuildContext context) => _InheritedComponentTheme(
this,
child: child,
);
}
class _InheritedComponentTheme extends InheritedWidget {
final ComponentTheme themeWidget;
const _InheritedComponentTheme(
this.themeWidget, {
required super.child,
});
@override
bool updateShouldNotify(covariant InheritedWidget oldWidget) =>
oldWidget != this;
}
@@ -0,0 +1,27 @@
// 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:wyatt_wyatt_ui_layout/src/domain/entities/components.dart';
class ComponentThemeData {
final AppBarComponent appBar;
final BottomNavigationBarComponent bottomNavigationBar;
const ComponentThemeData.raw({
required this.appBar,
required this.bottomNavigationBar,
});
}
@@ -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 'component_theme_data.dart';
export 'component_theme.dart';
@@ -0,0 +1,35 @@
// 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:wyatt_wyatt_ui_layout/src/core/extensions/build_context_extensions.dart';
import 'package:wyatt_wyatt_ui_layout/src/presentation/layouts/layout.dart';
class AppBarLayout extends Layout {
final String title;
final Widget body;
const AppBarLayout({
required this.title,
required this.body,
super.key,
});
@override
Widget build(BuildContext context) => Scaffold(
appBar: context.components.appBar.configure(title: title),
body: body,
);
}
@@ -0,0 +1,21 @@
import 'package:flutter/material.dart';
import 'package:wyatt_wyatt_ui_layout/src/core/core.dart';
import 'package:wyatt_wyatt_ui_layout/src/presentation/layouts/layout.dart';
class BottomNavigationBarLayout extends Layout {
final Widget body;
final int currentIndex;
const BottomNavigationBarLayout({
required this.currentIndex,
required this.body,
super.key,
});
@override
Widget build(BuildContext context) => Scaffold(
body: body,
bottomNavigationBar: context.components.bottomNavigationBar.configure(
currentIndex: currentIndex,
),
);
}
@@ -0,0 +1,5 @@
import 'package:flutter/material.dart';
abstract class Layout extends StatelessWidget {
const Layout({super.key});
}
@@ -0,0 +1,2 @@
export 'layouts/app_bar_layout.dart';
export 'layouts/bottom_navigation_bar_layout.dart';
+20
View File
@@ -0,0 +1,20 @@
// 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 'core/core.dart';
export 'domain/domain.dart';
export 'features/features.dart';
export 'presentation/presentation.dart';
@@ -0,0 +1,20 @@
// 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/>.
/// Wyatt Ui Layout
library wyatt_wyatt_ui_layout;
export 'src/src.dart';