From fa1d9504f557b5e367b974df3e9f0af90cd3afb5 Mon Sep 17 00:00:00 2001 From: Freek van de Ven Date: Fri, 5 Jul 2024 13:59:40 +0200 Subject: [PATCH] feat: add device preview package to the example app With Device Preview it is easy to view the userstory on different kinds of devices and change settings like language --- apps/example/lib/main.dart | 21 ++++++++++++++++++- apps/example/pubspec.yaml | 1 + .../src/ui/screens/availability_overview.dart | 1 - 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/apps/example/lib/main.dart b/apps/example/lib/main.dart index c97957c..fe12801 100644 --- a/apps/example/lib/main.dart +++ b/apps/example/lib/main.dart @@ -1,8 +1,19 @@ +import "package:device_preview/device_preview.dart"; import "package:flutter/material.dart"; import "package:flutter_availability/flutter_availability.dart"; void main() { - runApp(const App()); + runApp( + DevicePreview( + enabled: true, + isToolbarVisible: true, + availableLocales: const [ + Locale("en_US"), + Locale("nl_NL"), + ], + builder: (_) => const App(), + ), + ); } class App extends StatelessWidget { @@ -10,6 +21,14 @@ class App extends StatelessWidget { @override Widget build(BuildContext context) => MaterialApp( + builder: DevicePreview.appBuilder, + locale: DevicePreview.locale(context), + supportedLocales: const [ + Locale("en", "US"), + Locale("nl", "NL"), + ], + theme: ThemeData.light(), + darkTheme: ThemeData.dark(), home: AvailabilityUserStory( userId: "", options: AvailabilityOptions(), diff --git a/apps/example/pubspec.yaml b/apps/example/pubspec.yaml index fd6a662..2138d4d 100644 --- a/apps/example/pubspec.yaml +++ b/apps/example/pubspec.yaml @@ -9,6 +9,7 @@ environment: dependencies: flutter: sdk: flutter + device_preview: ^1.2.0 flutter_availability: path: ../../packages/flutter_availability diff --git a/packages/flutter_availability/lib/src/ui/screens/availability_overview.dart b/packages/flutter_availability/lib/src/ui/screens/availability_overview.dart index 0e9dc5e..d712556 100644 --- a/packages/flutter_availability/lib/src/ui/screens/availability_overview.dart +++ b/packages/flutter_availability/lib/src/ui/screens/availability_overview.dart @@ -17,7 +17,6 @@ class AvailabilityOverview extends StatelessWidget { /// Callback for when the user wants to navigate to the overview of templates final VoidCallback onViewTemplates; - /// Callback invoked when a user attempts to go back final VoidCallback onBack;