diff --git a/lib/main.dart b/lib/main.dart index bd3bab8..4b0f1db 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -72,7 +72,7 @@ class PanoramaxApp extends StatelessWidget { GlobalCupertinoLocalizations.delegate, ], supportedLocales: getSupportedLocales, - initialRoute: Routes.homepage, + initialRoute: Routes.newSequenceCapture, onGenerateRoute: generateRoutes, navigatorKey: GetIt.instance().navigatorkey); } diff --git a/lib/page/capture_page.dart b/lib/page/capture_page.dart index f60342c..b052622 100644 --- a/lib/page/capture_page.dart +++ b/lib/page/capture_page.dart @@ -1,9 +1,7 @@ part of panoramax; class CapturePage extends StatefulWidget { - const CapturePage({Key? key, required this.cameras}) : super(key: key); - - final List? cameras; + const CapturePage({Key? key}) : super(key: key); @override State createState() => _CapturePageState(); @@ -16,6 +14,7 @@ class _CapturePageState extends State with WidgetsBindingObserver { bool _isRearCameraSelected = true; bool _isPermissionDialogOpen = false; final List _imgListCaptured = []; + List? cameras; int _burstDuration = 3; //in seconds bool _isBurstMode = false; @@ -64,9 +63,14 @@ class _CapturePageState extends State with WidgetsBindingObserver { _stateHistoryList.add(WidgetsBinding.instance.lifecycleState!); } - if (widget.cameras?.isNotEmpty ?? false) { - initCamera(widget.cameras![0]); - } + availableCameras().then((value) { + setState(() { + cameras = value; + if (cameras?.isNotEmpty ?? false) { + initCamera(cameras![0]); + } + }); + }); } @override @@ -237,7 +241,7 @@ class _CapturePageState extends State with WidgetsBindingObserver { @override Widget build(BuildContext context) { - if (widget.cameras?.isEmpty ?? true) { + if (cameras?.isEmpty ?? true) { return Scaffold( appBar: AppBar(), body: Center( diff --git a/lib/page/homepage.dart b/lib/page/homepage.dart index 800bde5..f114713 100644 --- a/lib/page/homepage.dart +++ b/lib/page/homepage.dart @@ -39,9 +39,7 @@ class _HomePageState extends State { if (!await PermissionHelper.isPermissionGranted()) { await PermissionHelper.askMissingPermission(); } - await availableCameras().then( - (availableCameras) => GetIt.instance().pushTo(Routes.newSequenceCapture, arguments: availableCameras) - ); + GetIt.instance().pushTo(Routes.newSequenceCapture); } Widget displayBody(isLoading) { @@ -76,7 +74,8 @@ class _HomePageState extends State { child: Semantics( header: true, child: Text(AppLocalizations.of(context)!.yourSequence, - style: GoogleFonts.nunito(fontSize: 25, fontWeight: FontWeight.w400)), + style: GoogleFonts.nunito( + fontSize: 25, fontWeight: FontWeight.w400)), ), ), Expanded( @@ -106,7 +105,8 @@ class CollectionListView extends StatelessWidget { Widget build(BuildContext context) { return ListView.builder( itemCount: collections.length, - physics: const BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics()), + physics: + const BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics()), itemBuilder: (BuildContext context, int index) { return CollectionPreview(collections[index]); }, @@ -147,7 +147,8 @@ class NoElementView extends StatelessWidget { Center( child: Text( AppLocalizations.of(context)!.emptyError, - style: GoogleFonts.nunito(fontSize: 18, color: Colors.grey, fontWeight: FontWeight.w400), + style: GoogleFonts.nunito( + fontSize: 18, color: Colors.grey, fontWeight: FontWeight.w400), ), ) ], @@ -168,7 +169,8 @@ class UnknownErrorView extends StatelessWidget { Center( child: Text( AppLocalizations.of(context)!.unknownError, - style: GoogleFonts.nunito(fontSize: 20, color: Colors.red, fontWeight: FontWeight.w400), + style: GoogleFonts.nunito( + fontSize: 20, color: Colors.red, fontWeight: FontWeight.w400), ), ) ], diff --git a/lib/page/upload_pictures_page.dart b/lib/page/upload_pictures_page.dart index 9130034..5b8c8e4 100644 --- a/lib/page/upload_pictures_page.dart +++ b/lib/page/upload_pictures_page.dart @@ -69,10 +69,8 @@ class _UploadPicturesState extends State { } } - Future goToCapture() async { - await availableCameras().then((availableCameras) => - GetIt.instance() - .pushTo(Routes.newSequenceCapture, arguments: availableCameras)); + void goToCapture() { + GetIt.instance().pushTo(Routes.newSequenceCapture); } @override diff --git a/lib/service/routing.dart b/lib/service/routing.dart index 2d7ace3..6d073e5 100644 --- a/lib/service/routing.dart +++ b/lib/service/routing.dart @@ -1,15 +1,15 @@ part of panoramax; class Routes extends Equatable { - static const String homepage = "/"; - static const String newSequenceCapture = "/new-sequence/capture"; + //static const String homepage = "/"; + static const String newSequenceCapture = "/"; static const String newSequenceSend = "/new-sequence/send"; static const String instance = "/instance"; static const String newSequenceUpload = "/new-sequence/upload"; @override List get props => [ - homepage, + //homepage, newSequenceCapture, newSequenceSend, instance, @@ -24,11 +24,10 @@ class NavigationService { } dynamic pushReplacementTo(String route, {dynamic arguments}) { - return navigatorkey.currentState?.pushReplacementNamed(route, arguments: arguments); + return navigatorkey.currentState + ?.pushReplacementNamed(route, arguments: arguments); } - - dynamic goBack() { return navigatorkey.currentState?.pop(); } @@ -37,11 +36,7 @@ class NavigationService { Route generateRoutes(RouteSettings settings) { switch (settings.name) { case "/": - return MaterialPageRoute(builder: (_) => HomePage()); - case "/new-sequence/capture": - return MaterialPageRoute( - builder: (_) => CapturePage( - cameras: settings.arguments as List)); + return MaterialPageRoute(builder: (_) => CapturePage()); case "/new-sequence/send": return MaterialPageRoute( builder: (_) => CollectionCreationPage(