feat(ui_layout): add new package for app compenant and start implementing layouts
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:wyatt_wyatt_ui_layout/wyatt_wyatt_ui_layout.dart';
|
||||
|
||||
class CustomAppBar extends AppBarComponent {
|
||||
const CustomAppBar({
|
||||
super.title,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => AppBar(
|
||||
title: Text(title ?? ''),
|
||||
);
|
||||
|
||||
@override
|
||||
AppBarComponent configure({String? title}) => CustomAppBar(
|
||||
title: title ?? this.title,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:wyatt_wyatt_ui_layout/wyatt_wyatt_ui_layout.dart';
|
||||
|
||||
class CustomBottomNavigationBar extends BottomNavigationBarComponent {
|
||||
const CustomBottomNavigationBar({
|
||||
super.currentIndex,
|
||||
super.onTap,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => BottomNavigationBar(
|
||||
currentIndex: currentIndex,
|
||||
onTap: (index) => super.onTap?.call(context, index),
|
||||
items: const [
|
||||
BottomNavigationBarItem(
|
||||
label: 'Icon 1',
|
||||
icon: Icon(
|
||||
Icons.nearby_off,
|
||||
),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: 'Icon 2',
|
||||
icon: Icon(
|
||||
Icons.dangerous,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@override
|
||||
CustomBottomNavigationBar configure({
|
||||
void Function(BuildContext, int)? onTap,
|
||||
int currentIndex = 0,
|
||||
}) =>
|
||||
CustomBottomNavigationBar(
|
||||
onTap: onTap ?? this.onTap,
|
||||
currentIndex: currentIndex,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import 'package:flutter/material.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/pages/bottom_navigation_bar_layout_page_1.dart';
|
||||
import 'package:wyatt_ui_layout_example/pages/bottom_navigation_bar_layout_page_2.dart';
|
||||
import 'package:wyatt_wyatt_ui_layout/wyatt_wyatt_ui_layout.dart';
|
||||
|
||||
class AppThemeComponent {
|
||||
static ComponentThemeData get components => ComponentThemeData.raw(
|
||||
appBar: const CustomAppBar(),
|
||||
bottomNavigationBar: CustomBottomNavigationBar(
|
||||
onTap: (context, index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
// ignore: inference_failure_on_instance_creation
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
const BottomNavigationBarLayoutPage1(),
|
||||
transitionDuration: Duration.zero,
|
||||
reverseTransitionDuration: Duration.zero,
|
||||
),
|
||||
);
|
||||
break;
|
||||
case 1:
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
// ignore: inference_failure_on_instance_creation
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
const BottomNavigationBarLayoutPage2(),
|
||||
transitionDuration: Duration.zero,
|
||||
reverseTransitionDuration: Duration.zero,
|
||||
),
|
||||
);
|
||||
break;
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// 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_ui_layout_example/core/app_theme_component.dart';
|
||||
import 'package:wyatt_ui_layout_example/pages/available_layouts.dart';
|
||||
import 'package:wyatt_wyatt_ui_layout/wyatt_wyatt_ui_layout.dart';
|
||||
|
||||
void main() {
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
// This widget is the root of your application.
|
||||
@override
|
||||
Widget build(BuildContext context) => ComponentTheme(
|
||||
themDataWidget: AppThemeComponent.components,
|
||||
child: MaterialApp(
|
||||
title: 'Wyatt Ui Layout Example',
|
||||
theme: ThemeData(
|
||||
primarySwatch: Colors.blue,
|
||||
),
|
||||
home: const AvailabaleLayouts(),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:wyatt_wyatt_ui_layout/wyatt_wyatt_ui_layout.dart';
|
||||
|
||||
class AppBarLayoutPage extends StatelessWidget {
|
||||
const AppBarLayoutPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => const AppBarLayout(
|
||||
title: 'App Bar Layout',
|
||||
body: Center(
|
||||
child: Text(
|
||||
'Body',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:wyatt_ui_layout_example/pages/app_bar_layout_page.dart';
|
||||
import 'package:wyatt_ui_layout_example/pages/bottom_navigation_bar_layout_page_1.dart';
|
||||
import 'package:wyatt_wyatt_ui_layout/wyatt_wyatt_ui_layout.dart';
|
||||
|
||||
class AvailabaleLayouts extends StatelessWidget {
|
||||
const AvailabaleLayouts({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => AppBarLayout(
|
||||
title: 'Available Layouts',
|
||||
body: Center(
|
||||
child: SingleChildScrollView(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
// ignore: inference_failure_on_instance_creation
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const AppBarLayoutPage(),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: const Text(
|
||||
'App Bar Layout',
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
// ignore: inference_failure_on_instance_creation
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const BottomNavigationBarLayoutPage1(),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: const Text(
|
||||
'Bottom Navigation Bar Layout',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:wyatt_wyatt_ui_layout/wyatt_wyatt_ui_layout.dart';
|
||||
|
||||
class BottomNavigationBarLayoutPage1 extends StatelessWidget {
|
||||
const BottomNavigationBarLayoutPage1({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => const BottomNavigationBarLayout(
|
||||
currentIndex: 0,
|
||||
body: AppBarLayout(
|
||||
title: 'Bottom Bar Navigation Layout',
|
||||
body: Center(
|
||||
child: Text('Body'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:wyatt_wyatt_ui_layout/wyatt_wyatt_ui_layout.dart';
|
||||
|
||||
class BottomNavigationBarLayoutPage2 extends StatelessWidget {
|
||||
const BottomNavigationBarLayoutPage2({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => const BottomNavigationBarLayout(
|
||||
currentIndex: 1,
|
||||
body: AppBarLayout(
|
||||
title: 'Bottom Bar Navigation Layout',
|
||||
body: Center(
|
||||
child: Text('Body'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user