Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

Commit

Permalink
feat: remove homepage to launch the app on capture screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Aline Bonnet committed Jun 26, 2024
1 parent 3766eb2 commit 8405ee5
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 30 deletions.
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class PanoramaxApp extends StatelessWidget {
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: getSupportedLocales,
initialRoute: Routes.homepage,
initialRoute: Routes.newSequenceCapture,
onGenerateRoute: generateRoutes,
navigatorKey: GetIt.instance<NavigationService>().navigatorkey);
}
Expand Down
18 changes: 11 additions & 7 deletions lib/page/capture_page.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
part of panoramax;

class CapturePage extends StatefulWidget {
const CapturePage({Key? key, required this.cameras}) : super(key: key);

final List<CameraDescription>? cameras;
const CapturePage({Key? key}) : super(key: key);

@override
State<CapturePage> createState() => _CapturePageState();
Expand All @@ -16,6 +14,7 @@ class _CapturePageState extends State<CapturePage> with WidgetsBindingObserver {
bool _isRearCameraSelected = true;
bool _isPermissionDialogOpen = false;
final List<File> _imgListCaptured = [];
List<CameraDescription>? cameras;

int _burstDuration = 3; //in seconds
bool _isBurstMode = false;
Expand Down Expand Up @@ -64,9 +63,14 @@ class _CapturePageState extends State<CapturePage> 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
Expand Down Expand Up @@ -237,7 +241,7 @@ class _CapturePageState extends State<CapturePage> with WidgetsBindingObserver {

@override
Widget build(BuildContext context) {
if (widget.cameras?.isEmpty ?? true) {
if (cameras?.isEmpty ?? true) {
return Scaffold(
appBar: AppBar(),
body: Center(
Expand Down
16 changes: 9 additions & 7 deletions lib/page/homepage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ class _HomePageState extends State<HomePage> {
if (!await PermissionHelper.isPermissionGranted()) {
await PermissionHelper.askMissingPermission();
}
await availableCameras().then(
(availableCameras) => GetIt.instance<NavigationService>().pushTo(Routes.newSequenceCapture, arguments: availableCameras)
);
GetIt.instance<NavigationService>().pushTo(Routes.newSequenceCapture);
}

Widget displayBody(isLoading) {
Expand Down Expand Up @@ -76,7 +74,8 @@ class _HomePageState extends State<HomePage> {
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(
Expand Down Expand Up @@ -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]);
},
Expand Down Expand Up @@ -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),
),
)
],
Expand All @@ -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),
),
)
],
Expand Down
6 changes: 2 additions & 4 deletions lib/page/upload_pictures_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,8 @@ class _UploadPicturesState extends State<UploadPicturesPage> {
}
}

Future<void> goToCapture() async {
await availableCameras().then((availableCameras) =>
GetIt.instance<NavigationService>()
.pushTo(Routes.newSequenceCapture, arguments: availableCameras));
void goToCapture() {
GetIt.instance<NavigationService>().pushTo(Routes.newSequenceCapture);
}

@override
Expand Down
17 changes: 6 additions & 11 deletions lib/service/routing.dart
Original file line number Diff line number Diff line change
@@ -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<Object?> get props => [
homepage,
//homepage,
newSequenceCapture,
newSequenceSend,
instance,
Expand All @@ -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();
}
Expand All @@ -37,11 +36,7 @@ class NavigationService {
Route<dynamic> generateRoutes(RouteSettings settings) {
switch (settings.name) {
case "/":
return MaterialPageRoute(builder: (_) => HomePage());
case "/new-sequence/capture":
return MaterialPageRoute(
builder: (_) => CapturePage(
cameras: settings.arguments as List<CameraDescription>));
return MaterialPageRoute(builder: (_) => CapturePage());
case "/new-sequence/send":
return MaterialPageRoute(
builder: (_) => CollectionCreationPage(
Expand Down

0 comments on commit 8405ee5

Please sign in to comment.