feat(ui_kit): update example with drawer and custom launch parameters

This commit is contained in:
Hugo Pointcheval 2023-02-14 12:50:46 +01:00
parent 82eeba4d7d
commit c942e2aacf
Signed by: hugo
GPG Key ID: 3AAC487E131E00BC
8 changed files with 118 additions and 65 deletions

View File

@ -1,16 +1,9 @@
# example
# Wyatt UIKIt Example
A new Flutter project.
You can force the launch page. (For debug purposes).
## Getting Started
```shell
flutter run -d macos --dart-define PAGE=1
```
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
> This will forces button page.

View File

@ -36,38 +36,43 @@ class Buttons extends StatelessWidget {
const Buttons({super.key});
@override
Widget build(BuildContext context) => Column(
Widget build(BuildContext context) => ListView(
children: [
Text(
'Buttons',
style: Theme.of(context).textTheme.titleLarge,
const Gap(20),
Align(
child: Text(
'Buttons',
style: Theme.of(context).textTheme.titleLarge,
),
),
const Gap(20),
FlatButton(
label: const TextWrapper('Voir notre savoir faire'),
normalStyle: const FlatButtonStyle(
foregroundColors: MultiColor(_colors),
backgroundColors: MultiColor.single(Colors.transparent),
borderColors: MultiColor(_colors),
stroke: 3,
),
hoveredStyle: const FlatButtonStyle(
foregroundColors: MultiColor.single(Colors.white),
backgroundColors: MultiColor(_colors),
borderColors: MultiColor(_colors),
stroke: 3,
),
tappedStyle: const FlatButtonStyle(
foregroundColors: MultiColor.single(Colors.white),
backgroundColors: MultiColor(_colorsDarken),
borderColors: MultiColor(_colorsDarken),
stroke: 3,
),
prefix: const Icon(
Icons.arrow_forward_rounded,
),
suffix: const Icon(
Icons.arrow_forward_rounded,
Center(
child: FlatButton(
label: const TextWrapper('Voir notre savoir faire'),
normalStyle: const FlatButtonStyle(
foregroundColors: MultiColor(_colors),
backgroundColors: MultiColor.single(Colors.transparent),
borderColors: MultiColor(_colors),
stroke: 3,
),
hoveredStyle: const FlatButtonStyle(
foregroundColors: MultiColor.single(Colors.white),
backgroundColors: MultiColor(_colors),
borderColors: MultiColor(_colors),
stroke: 3,
),
tappedStyle: const FlatButtonStyle(
foregroundColors: MultiColor.single(Colors.white),
backgroundColors: MultiColor(_colorsDarken),
borderColors: MultiColor(_colorsDarken),
stroke: 3,
),
prefix: const Icon(
Icons.arrow_forward_rounded,
),
suffix: const Icon(
Icons.arrow_forward_rounded,
),
),
),
const Gap(20),

View File

@ -9,11 +9,14 @@ class Cards extends StatelessWidget {
const Cards({super.key});
@override
Widget build(BuildContext context) => Column(
Widget build(BuildContext context) => ListView(
children: [
Text(
'Cards',
style: Theme.of(context).textTheme.titleLarge,
const Gap(20),
Align(
child: Text(
'Cards',
style: Theme.of(context).textTheme.titleLarge,
),
),
const Gap(20),
const InformationCards(),

View File

@ -1,20 +1,61 @@
import 'package:adaptive_theme/adaptive_theme.dart';
import 'package:flutter/material.dart';
import 'package:wyatt_ui_kit_example/buttons/buttons.dart';
import 'package:wyatt_ui_kit_example/cards/cards.dart';
const String title = 'Wyatt Ui Kit Example';
const String title = 'Wyatt UIKit Example';
class Home extends StatefulWidget {
const Home({super.key});
const Home({super.key, this.forceIndex = 0});
final int forceIndex;
@override
State<Home> createState() => _HomeState();
}
class _HomeState extends State<Home> {
final List<Widget> pages = const [Cards(), Buttons()];
int currentIndex = 0;
@override
void initState() {
currentIndex = widget.forceIndex;
super.initState();
}
@override
Widget build(BuildContext context) => Scaffold(
drawer: const Drawer(),
drawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: [
ListTile(
title: const Text('Cards'),
onTap: () {
if (currentIndex != 0) {
setState(() {
currentIndex = 0;
});
Navigator.pop(context);
}
},
),
ListTile(
title: const Text('Buttons'),
onTap: () {
if (currentIndex != 1) {
setState(() {
currentIndex = 1;
});
Navigator.pop(context);
}
},
),
],
),
),
appBar: AppBar(
title: const Text(title),
actions: [
@ -30,10 +71,7 @@ class _HomeState extends State<Home> {
),
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: ListView(
shrinkWrap: true,
children: const [Cards()],
),
child: pages[currentIndex],
),
);
}

View File

@ -22,13 +22,16 @@ import 'package:wyatt_ui_kit_example/home.dart';
import 'package:wyatt_ui_kit_example/theme_extension.dart';
void main(List<String> args) {
runApp(const App());
const forcePage = int.fromEnvironment('PAGE');
runApp(const App(
defaultPage: forcePage,
),);
}
class App extends StatelessWidget {
const App({super.key});
const App({required this.defaultPage, super.key});
static const String title = 'Wyatt Ui Kit Example';
final int defaultPage;
@override
Widget build(BuildContext context) => AdaptiveTheme(
@ -125,7 +128,9 @@ class App extends StatelessWidget {
Locale('fr', ''),
],
title: title,
home: const Home(),
home: Home(
forceIndex: defaultPage,
),
),
);
}

View File

@ -3,20 +3,27 @@ PODS:
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
DEPENDENCIES:
- FlutterMacOS (from `Flutter/ephemeral`)
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/macos`)
- shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/macos`)
EXTERNAL SOURCES:
FlutterMacOS:
:path: Flutter/ephemeral
path_provider_foundation:
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/macos
shared_preferences_foundation:
:path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/macos
SPEC CHECKSUMS:
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
path_provider_foundation: 37748e03f12783f9de2cb2c4eadfaa25fe6d4852
shared_preferences_foundation: 297b3ebca31b34ec92be11acd7fb0ba932c822ca
PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
</dict>
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
</dict>
</plist>

View File

@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.app-sandbox</key>
<true/>
</dict>