Skip to content

Commit

Permalink
feat: new home page
Browse files Browse the repository at this point in the history
  • Loading branch information
luisburgos committed Sep 22, 2022
1 parent 6f427f1 commit 7cc5be1
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 40 deletions.
5 changes: 4 additions & 1 deletion example/lib/get/core_module.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:buzz/buzz.dart';
import 'package:example/shared/app_routes.dart';
import 'package:get/get.dart';

import 'extensions/get_module.dart';
Expand All @@ -12,7 +13,9 @@ class CoreModule extends GetModule {
@override
List<GetRoute> get routes => [
GetModuleRoute(
module: HomeModule(),
module: HomeModule(
profileRoute: AppRoutes.profileRoot,
),
),
GetModuleRoute(
module: ProfileModule(),
Expand Down
36 changes: 34 additions & 2 deletions example/lib/get/home/module.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,41 @@
import 'package:buzz/buzz.dart';
import 'package:get/get.dart';

import '../../shared/modules/home/page.dart';
import '../extensions/get_module.dart';
import 'page.dart';

class HomeModule extends GetModule {
final String profileRoute;

HomeModule({
required this.profileRoute,
});

@override
List<GetRoute> get routes => [
HomeRoute(),
HomeRoute(profileRoute),
];
}

class HomeRoute extends GetRoute {
HomeRoute(this.profileRoute);

final String profileRoute;

@override
GetPage get asGetPage => GetPage(
name: HomePage.routeName,
page: () => HomePage(
onNewTriviaGameTap: () {
Buzz.fire(
NavigateToCommand.named(profileRoute),
);
},
onGoToBuzzTap: () {
Buzz.fire(
GoToBuzzEventsDashboard(),
);
},
),
);
}
25 changes: 0 additions & 25 deletions example/lib/get/home/page.dart

This file was deleted.

File renamed without changes.
6 changes: 3 additions & 3 deletions example/lib/modular/home/home_module.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:buzz/buzz.dart';
import 'package:example/shared/modules/home/home_page.dart';
import 'package:example/shared/modules/home/page.dart';
import 'package:flutter_modular/flutter_modular.dart';

import '../../shared/app_routes.dart';
Expand All @@ -10,12 +10,12 @@ class HomeModule extends Module {
ChildRoute(
AppRoutes.root,
child: (context, args) => HomePage(
onGoToBuzzTapped: () {
onGoToBuzzTap: () {
Buzz.fire(
GoToBuzzEventsDashboard(),
);
},
onGoToProfileTapped: () {
onNewTriviaGameTap: () {
Buzz.fire(
NavigateToCommand.named(AppRoutes.profileRoot),
);
Expand Down
4 changes: 3 additions & 1 deletion example/lib/shared/app_routes.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'package:example/shared/modules/home/page.dart';

class AppRoutes {
static const root = '/';
static const root = HomePage.routeName;
static const profileRoot = '/profile';
static const notFound = '/not-found';
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,35 @@ import 'package:core/core.dart';
import 'package:flutter/material.dart';

class HomePage extends StatelessWidget {
static const String routeName = '/';
static const String pageName = 'HomePage';

const HomePage({
Key? key,
required this.onGoToBuzzTapped,
required this.onGoToProfileTapped,
required this.onGoToBuzzTap,
required this.onNewTriviaGameTap,
}) : super(key: key);

final Function() onGoToBuzzTapped;
final Function() onGoToProfileTapped;
final Function() onGoToBuzzTap;
final Function() onNewTriviaGameTap;

@override
Widget build(BuildContext context) {
return BasePage(
name: 'Home',
actions: [
MainAction(
label: 'Go to Profile',
label: 'New trivia game',
onPressed: () {
debugPrint('$runtimeType onGoToProfileTapped');
onGoToProfileTapped();
debugPrint('$runtimeType onNewTriviaGameTap');
onNewTriviaGameTap();
},
),
MainAction(
label: 'Go to Buzz',
onPressed: () {
debugPrint('$runtimeType onGoToBuzzTapped');
onGoToBuzzTapped();
onGoToBuzzTap();
},
)
],
Expand Down
1 change: 1 addition & 0 deletions example/lib/shared/modules/trivia/new_trivia.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

24 changes: 24 additions & 0 deletions example/lib/shared/modules/trivia/trivia.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'package:flutter/material.dart';

class HomePage {
static const String routeName = '/';
static const String pageName = 'HomePage';

Widget viewBuilder() => const HomeView();
}

class HomeView extends StatelessWidget {
const HomeView({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: ElevatedButton(
child: const Text('New trivia game'),
onPressed: () {},
),
),
);
}
}

0 comments on commit 7cc5be1

Please sign in to comment.