Skip to content
Open
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
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,8 @@ packages-upgrade:
l10n:
flutter gen-l10n
appicon:
flutter pub run flutter_launcher_icons:main -f flutter_launcher_icons.yaml
flutter pub run flutter_launcher_icons:main -f flutter_launcher_icons.yaml
deeplink:
@printf "Android:\nadb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d 'counter:///counters/2'"
@printf "\n\n"
@printf "iOS:\nxcrun simctl openurl booted counter:///counters/2"
8 changes: 8 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- Deep linking -->
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="counter" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
Expand Down
17 changes: 17 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,22 @@
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<!-- Add this array for Deep Links -->
<key>FlutterDeepLinkingEnabled</key>
<true/>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>counter.de</string>
<key>CFBundleURLSchemes</key>
<array>
<string>de.coodoo.counter</string>
<string>counter</string>
</array>
</dict>
</array>
</dict>
</plist>
8 changes: 5 additions & 3 deletions lib/src/app.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:counter_workshop/src/core/routing/router.dart';
import 'package:counter_workshop/src/core/theme/app.theme.dart';
import 'package:counter_workshop/src/features/counter/data/repositories/counter.repository.dart';
import 'package:counter_workshop/src/features/counter/presentation/dashboard/bloc/dashboard.bloc.dart';
import 'package:counter_workshop/src/features/counter/presentation/dashboard/bloc/dashboard.event.dart';
import 'package:counter_workshop/src/features/counter/presentation/dashboard/view/dashboard.page.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

Expand Down Expand Up @@ -45,12 +45,14 @@ class AppView extends StatelessWidget {
@override
Widget build(BuildContext context) {
final appTheme = AppTheme();
return MaterialApp(
return MaterialApp.router(
title: 'Counter Demo',
theme: appTheme.light,
darkTheme: appTheme.dark,
themeMode: ThemeMode.system,
home: const DashboardPage(),
routeInformationProvider: router.routeInformationProvider,
routeInformationParser: router.routeInformationParser,
routerDelegate: router.routerDelegate,
);
}
}
31 changes: 31 additions & 0 deletions lib/src/core/routing/router.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'package:counter_workshop/src/features/counter/presentation/dashboard/view/dashboard.page.dart';
import 'package:counter_workshop/src/features/counter/presentation/edit/view/edit_counter.page.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

final router = GoRouter(
debugLogDiagnostics: true,
initialLocation: '/counters',
routes: [
GoRoute(
path: '/counters',
builder: (context, state) => const DashboardPage(),
routes: [
GoRoute(
path: 'new',
pageBuilder: (context, state) => const MaterialPage(
fullscreenDialog: true,
child: EditCounterPage(),
),
),
GoRoute(
path: ':id',
builder: (context, state) {
final counterId = state.pathParameters['id'];
return EditCounterPage(counterId: counterId!);
},
),
],
),
],
);
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import 'package:counter_workshop/src/core/widgets/error_message.widget.dart';
import 'package:counter_workshop/src/features/counter/presentation/dashboard/bloc/dashboard.bloc.dart';
import 'package:counter_workshop/src/features/counter/presentation/dashboard/bloc/dashboard.state.dart';
import 'package:counter_workshop/src/features/counter/presentation/dashboard/view/widgets/counter_grid.dart';
import 'package:counter_workshop/src/features/counter/presentation/edit/view/edit_counter.page.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';

/// bloc
class DashboardPage extends StatelessWidget {
Expand Down Expand Up @@ -38,7 +38,7 @@ class DashboardPage extends StatelessWidget {
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.add),
onPressed: () {
Navigator.push(context, EditCounterPage.route(fullscreen: true));
context.go('/counters/new');
},
),
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:counter_workshop/src/features/counter/domain/model/counter.model.dart';
import 'package:counter_workshop/src/features/counter/presentation/edit/view/edit_counter.page.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

class CounterGrid extends StatelessWidget {
const CounterGrid({
Expand All @@ -26,7 +26,7 @@ class CounterGrid extends StatelessWidget {
final counterModel = counterList[index];
return Card(
child: InkWell(
onTap: () => Navigator.push(context, EditCounterPage.route(counterId: counterModel.id)),
onTap: () => context.push('/counters/${counterModel.id}'),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,6 @@ class EditCounterPage extends StatelessWidget {
const EditCounterPage({this.counterId, super.key});
final String? counterId;

static Route<void> route({String? counterId, bool fullscreen = false}) {
return MaterialPageRoute(
fullscreenDialog: fullscreen,
builder: (context) => BlocProvider(
create: (context) => EditCounterBloc(
counterRepository: context.read<CounterRepository>(),
counterId: counterId,
),
child: EditCounterPage(counterId: counterId),
),
);
}

@override
Widget build(BuildContext context) {
final bloc = EditCounterBloc(
Expand Down
9 changes: 5 additions & 4 deletions macos/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 51;
objectVersion = 54;
objects = {

/* Begin PBXAggregateTarget section */
Expand Down Expand Up @@ -235,6 +235,7 @@
/* Begin PBXShellScriptBuildPhase section */
3399D490228B24CF009A79C7 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -344,7 +345,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down Expand Up @@ -423,7 +424,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -470,7 +471,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down
Loading