Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use native navigation instead of getX navigation #6

Merged
merged 11 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/fluorflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class MyApp extends StatelessWidget {
initialRoute: AppRoute.homeView.path,
onGenerateRoute: onGenerateRoute,
navigatorKey: NavigationService.navigatorKey,
navigatorObservers: [NavigationService.observer()],
navigatorObservers: [NavigationService.observer],
);
}
}
Expand All @@ -41,12 +41,12 @@ Especially the part for routing is important (if you use FluorFlow views and rou
initialRoute: AppRoute.homeView.path,
onGenerateRoute: onGenerateRoute,
navigatorKey: NavigationService.navigatorKey,
navigatorObservers: [NavigationService.observer()],
navigatorObservers: [NavigationService.observer],
```

This enables the routing system of FluorFlow (which uses GetX underneath).
This enables the routing system of FluorFlow.

The other parts of the material app can be as you wish.
The other parts of the app can be as you wish.

## Views

Expand Down Expand Up @@ -176,12 +176,12 @@ final class GreetingBottomSheet extends FluorFlowSimpleBottomSheet<void> {
}
```

Bottom sheets are shown via the `BottomSheetService` that has extension methods
Bottom sheets are shown via the `NavigationService` that has extension methods
attached for each bottom sheet. Parameters of sheets are taken into account
when used with the fluorflow generator.

Dialogs work exactly the same way as bottom sheets, but are shown via the
`DialogService` and have another base class.
`Dialogs` extension in the `NavigationService` and have another base class.

**Important:** Bottom sheets are always wrapped in a `Scaffold` widget. Thus,
they inherit your styles. `Dialogs` do not have this behavior (by design).
Expand Down
2 changes: 1 addition & 1 deletion packages/fluorflow/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ class MyApp extends StatelessWidget {
initialRoute: AppRoute.homeView.path,
onGenerateRoute: onGenerateRoute,
navigatorKey: NavigationService.navigatorKey,
navigatorObservers: [NavigationService.observer()],
navigatorObservers: [NavigationService.observer],
);
}
4 changes: 4 additions & 0 deletions packages/fluorflow/example/lib/views/detail/detail_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ final class DetailView extends FluorFlowView<DetailViewModel> {
onPressed: viewModel.back,
child: const Text('Back'),
),
ElevatedButton(
onPressed: viewModel.rootBack,
child: const Text('Root to home view'),
),
ElevatedButton(
onPressed: viewModel.showBottomSheet,
child: const Text('Show Bottom Sheet'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import 'dart:async';

import 'package:example/app.bottom_sheets.dart';
import 'package:fluorflow/fluorflow.dart';

import '../../app.router.dart';

final class DetailViewModel extends DataViewModel<int> {
final _navService = locator<NavigationService>();
final _sheets = locator<BottomSheetService>();

DetailViewModel() : super(0);

void showBottomSheet() =>
_sheets.showGreetingBottomSheet(callback: () {}, onElement: (_) {});
_navService.showGreetingBottomSheet(callback: () {}, onElement: (_) {});

void back() => _navService.back();

void rootBack() => _navService.rootToHomeView();

void addOne() => data += 1;
}
5 changes: 2 additions & 3 deletions packages/fluorflow/example/lib/views/home/home_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import '../../app.dialogs.dart';
import '../../app.router.dart';

final class HomeViewModel extends BaseViewModel {
final _dialogService = locator<DialogService>();
final _navService = locator<NavigationService>();

var _counter = 0;
Expand All @@ -16,9 +15,9 @@ final class HomeViewModel extends BaseViewModel {
notifyListeners();
}

void showTestDialog() => _dialogService.showRedDialog(elements: []);
void showTestDialog() => _navService.showRedDialog(elements: []);
buehler marked this conversation as resolved.
Show resolved Hide resolved

void showSmallDialog() => _dialogService.showSmallDialog();
void showSmallDialog() => _navService.showSmallDialog();

void goToDetail() => _navService.navigateToDetailView();
}
2 changes: 0 additions & 2 deletions packages/fluorflow/lib/fluorflow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
library fluorflow;

export 'src/bottom_sheets/bottom_sheet.dart';
export 'src/bottom_sheets/bottom_sheet_service.dart';
export 'src/bottom_sheets/simple_bottom_sheet.dart';
export 'src/dialogs/dialog.dart';
export 'src/dialogs/dialog_service.dart';
export 'src/dialogs/simple_dialog.dart';
export 'src/locator/locator.dart';
export 'src/navigation/navigation_service.dart';
Expand Down
10 changes: 7 additions & 3 deletions packages/fluorflow/lib/src/annotations/bottom_sheet_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,22 @@ class BottomSheetConfig {
/// If set to false, the bottom sheet will be displayed at the bottom third(-ish) of the screen.
final bool defaultFullscreen;

/// Whether the bottom sheet should ignore the safe area and take up the entire screen.
/// Whether the bottom sheet should ignore or use the safe area and take up the entire screen.
/// This is most likely used in combination with [defaultFullscreen].
final bool defaultIgnoreSafeArea;
final bool defaultUseSafeArea;

/// Whether the bottom sheet can be dragged by the user.
final bool defaultDraggable;

/// Whether the bottom sheet should show a drag handle.
final bool defaultShowDragHandle;

/// Decorate a bottom sheet or simple bottomsheet with a [BottomSheetConfig].
const BottomSheetConfig({
this.defaultBarrierColor = 0x80000000,
this.defaultFullscreen = false,
this.defaultIgnoreSafeArea = true,
this.defaultUseSafeArea = false,
this.defaultDraggable = true,
this.defaultShowDragHandle = false,
});
}
43 changes: 0 additions & 43 deletions packages/fluorflow/lib/src/bottom_sheets/bottom_sheet_service.dart

This file was deleted.

39 changes: 0 additions & 39 deletions packages/fluorflow/lib/src/dialogs/dialog_service.dart

This file was deleted.

Loading