From 85c0bb9a6e3f2465603c9cc417c9214b2a659769 Mon Sep 17 00:00:00 2001 From: Hugo Pointcheval Date: Tue, 14 Feb 2023 12:50:46 +0100 Subject: [PATCH] feat(ui_kit): update example with drawer and custom launch parameters --- packages/wyatt_ui_kit/example/README.md | 19 ++---- .../example/lib/buttons/buttons.dart | 63 ++++++++++--------- .../wyatt_ui_kit/example/lib/cards/cards.dart | 11 ++-- packages/wyatt_ui_kit/example/lib/home.dart | 52 ++++++++++++--- packages/wyatt_ui_kit/example/lib/main.dart | 13 ++-- .../wyatt_ui_kit/example/macos/Podfile.lock | 7 +++ .../macos/Runner/DebugProfile.entitlements | 16 ++--- .../example/macos/Runner/Release.entitlements | 2 + 8 files changed, 118 insertions(+), 65 deletions(-) diff --git a/packages/wyatt_ui_kit/example/README.md b/packages/wyatt_ui_kit/example/README.md index 2b3fce4c..510ce200 100644 --- a/packages/wyatt_ui_kit/example/README.md +++ b/packages/wyatt_ui_kit/example/README.md @@ -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. \ No newline at end of file diff --git a/packages/wyatt_ui_kit/example/lib/buttons/buttons.dart b/packages/wyatt_ui_kit/example/lib/buttons/buttons.dart index 8d9cbd9f..010d26f3 100644 --- a/packages/wyatt_ui_kit/example/lib/buttons/buttons.dart +++ b/packages/wyatt_ui_kit/example/lib/buttons/buttons.dart @@ -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), diff --git a/packages/wyatt_ui_kit/example/lib/cards/cards.dart b/packages/wyatt_ui_kit/example/lib/cards/cards.dart index c0a4fe7d..4c99cdea 100644 --- a/packages/wyatt_ui_kit/example/lib/cards/cards.dart +++ b/packages/wyatt_ui_kit/example/lib/cards/cards.dart @@ -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(), diff --git a/packages/wyatt_ui_kit/example/lib/home.dart b/packages/wyatt_ui_kit/example/lib/home.dart index 2d2d7c20..69ab4cec 100644 --- a/packages/wyatt_ui_kit/example/lib/home.dart +++ b/packages/wyatt_ui_kit/example/lib/home.dart @@ -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 createState() => _HomeState(); } class _HomeState extends State { + final List 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 { ), body: Padding( padding: const EdgeInsets.symmetric(horizontal: 8), - child: ListView( - shrinkWrap: true, - children: const [Cards()], - ), + child: pages[currentIndex], ), ); } diff --git a/packages/wyatt_ui_kit/example/lib/main.dart b/packages/wyatt_ui_kit/example/lib/main.dart index 70f24dac..48398c02 100644 --- a/packages/wyatt_ui_kit/example/lib/main.dart +++ b/packages/wyatt_ui_kit/example/lib/main.dart @@ -22,13 +22,16 @@ import 'package:wyatt_ui_kit_example/home.dart'; import 'package:wyatt_ui_kit_example/theme_extension.dart'; void main(List 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, + ), ), ); } diff --git a/packages/wyatt_ui_kit/example/macos/Podfile.lock b/packages/wyatt_ui_kit/example/macos/Podfile.lock index d1fc289f..9127443a 100644 --- a/packages/wyatt_ui_kit/example/macos/Podfile.lock +++ b/packages/wyatt_ui_kit/example/macos/Podfile.lock @@ -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 diff --git a/packages/wyatt_ui_kit/example/macos/Runner/DebugProfile.entitlements b/packages/wyatt_ui_kit/example/macos/Runner/DebugProfile.entitlements index dddb8a30..dccb3959 100644 --- a/packages/wyatt_ui_kit/example/macos/Runner/DebugProfile.entitlements +++ b/packages/wyatt_ui_kit/example/macos/Runner/DebugProfile.entitlements @@ -1,12 +1,12 @@ - - com.apple.security.app-sandbox - - com.apple.security.cs.allow-jit - - com.apple.security.network.server - - + + com.apple.security.app-sandbox + + com.apple.security.cs.allow-jit + + com.apple.security.network.server + + diff --git a/packages/wyatt_ui_kit/example/macos/Runner/Release.entitlements b/packages/wyatt_ui_kit/example/macos/Runner/Release.entitlements index 852fa1a4..3618034f 100644 --- a/packages/wyatt_ui_kit/example/macos/Runner/Release.entitlements +++ b/packages/wyatt_ui_kit/example/macos/Runner/Release.entitlements @@ -2,6 +2,8 @@ + com.apple.security.network.client + com.apple.security.app-sandbox