From 6188a4c545e6e6794eba943431ec20108553b98f Mon Sep 17 00:00:00 2001 From: Scott Murray Date: Wed, 31 Jul 2024 11:30:22 -0400 Subject: Add support for CI screenshot testing Rework the high-level App & AppView widgets a bit to allow conditionally displaying a simple fixed pattern if the HOMESCREEN_DEMO_CI environment variable is set to anything other than "0". The pattern displayed matches what the Qt homescreen shows for this to allow the CI test to be common. Bug-AGL: SPEC-5203 Change-Id: I36ed77c91304e3b6cdbce6a7350831d52d20d378 Signed-off-by: Scott Murray (cherry picked from commit 25b6a079d5fe9c1365d776298ae5230a4de1ba16) --- lib/data/data_providers/app.dart | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'lib/data') diff --git a/lib/data/data_providers/app.dart b/lib/data/data_providers/app.dart index acfaa01..3368a83 100644 --- a/lib/data/data_providers/app.dart +++ b/lib/data/data_providers/app.dart @@ -1,25 +1,32 @@ import '../../export.dart'; +final homeScreenProvider = Provider((ref) { + final Map envVars = Platform.environment; + final ciFlagStr = envVars['HOMESCREEN_DEMO_CI']; + final bool ciFlag = ciFlagStr != null && ciFlagStr != "0"; + return ciFlag ? const HomeScreenCI() : const HomeScreen(); +}); + class App extends StatelessWidget { const App({super.key}); - @override - Widget build(BuildContext context) { - return const AppView(); - } -} - -class AppView extends StatelessWidget { - const AppView({super.key}); - @override Widget build(BuildContext context) { return ProviderScope( child: MaterialApp( debugShowCheckedModeBanner: false, theme: theme, - home: const HomeScreen(), + home: const AppView(), ), ); } } + +class AppView extends ConsumerWidget { + const AppView({super.key}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + return ref.watch(homeScreenProvider); + } +} -- cgit 1.2.3-korg