Skip to content

Commit

Permalink
Merge pull request #146 from yumemi-inc/feature/add-license
Browse files Browse the repository at this point in the history
feat(setting): ライセンスページを追加
  • Loading branch information
tatsutakein committed Feb 27, 2024
2 parents 628ff82 + b305420 commit e488705
Show file tree
Hide file tree
Showing 21 changed files with 245 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:cores_navigation/navigators.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app/router/routes/home_route.dart';
import 'package:flutter_app/router/routes/setting_route.dart';

final class HomeNavigatorImpl implements HomeNavigator {
const HomeNavigatorImpl();
Expand Down
13 changes: 13 additions & 0 deletions apps/app/lib/router/navigator/setting_navigator.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'package:cores_navigation/navigators.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app/router/routes/home_route.dart';
import 'package:flutter_app/router/routes/setting_route.dart';

final class SettingNavigatorImpl implements SettingNavigator {
const SettingNavigatorImpl();

@override
void goLicensePage(BuildContext context) {
const LicensePageRoute().go(context);
}
}
19 changes: 3 additions & 16 deletions apps/app/lib/router/routes/home_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import 'dart:async';
import 'package:cores_core/util.dart';
import 'package:cores_navigation/providers.dart';
import 'package:features_debug_mode/ui.dart';
import 'package:features_setting/setting.dart';
import 'package:features_webview/webview.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app/feature/home/ui/home_navigator.dart';
import 'package:flutter_app/feature/home/ui/home_page.dart';
import 'package:flutter_app/router/navigator/home_navigator.dart';
import 'package:flutter_app/router/routes/setting_route.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';

Expand All @@ -16,9 +16,7 @@ part 'home_route.g.dart';
@TypedGoRoute<HomePageRoute>(
path: HomePageRoute.path,
routes: [
TypedGoRoute<SettingPageRoute>(
path: SettingPageRoute.path,
),
settingPageRoute,
TypedGoRoute<DebugModePageRoute>(
path: DebugModePageRoute.path,
),
Expand Down Expand Up @@ -51,17 +49,6 @@ class HomePageRoute extends GoRouteData {
}
}

class SettingPageRoute extends GoRouteData {
const SettingPageRoute();

static const path = 'setting';

@override
Widget build(BuildContext context, GoRouterState state) {
return const SettingPage();
}
}

class DebugModePageRoute extends GoRouteData {
const DebugModePageRoute();

Expand Down
24 changes: 24 additions & 0 deletions apps/app/lib/router/routes/home_route.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions apps/app/lib/router/routes/setting_route.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import 'package:cores_navigation/providers.dart';
import 'package:features_setting/setting.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app/router/navigator/setting_navigator.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';

const settingPageRoute = TypedGoRoute<SettingPageRoute>(
path: SettingPageRoute.path,
routes: [
TypedGoRoute<LicensePageRoute>(
path: LicensePageRoute.path,
),
],
);

final class SettingPageRoute extends GoRouteData {
const SettingPageRoute();

static const path = 'setting';

@override
Widget build(BuildContext context, GoRouterState state) {
return ProviderScope(
overrides: [
settingNavigatorProvider.overrideWithValue(
const SettingNavigatorImpl(),
),
],
child: const SettingPage(),
);
}
}

final class LicensePageRoute extends GoRouteData {
const LicensePageRoute();

static const path = 'license';

@override
Widget build(BuildContext context, GoRouterState state) {
return const LicensePage();
}
}
1 change: 1 addition & 0 deletions packages/cores/navigation/lib/navigators.dart
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export 'src/home/navigator.dart';
export 'src/setting/navigator.dart';
1 change: 1 addition & 0 deletions packages/cores/navigation/lib/providers.dart
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export 'src/home/provider.dart';
export 'src/setting/provider.dart';
5 changes: 5 additions & 0 deletions packages/cores/navigation/lib/src/setting/navigator.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'package:flutter/material.dart';

abstract interface class SettingNavigator {
void goLicensePage(BuildContext context);
}
7 changes: 7 additions & 0 deletions packages/cores/navigation/lib/src/setting/provider.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import 'package:cores_navigation/src/setting/navigator.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'provider.g.dart';

@riverpod
external SettingNavigator settingNavigator(SettingNavigatorRef ref);
28 changes: 28 additions & 0 deletions packages/cores/navigation/lib/src/setting/provider.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions packages/features/setting/assets/l10n/app_en.arb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"settingAppBar": "Setting",
"settingThemeSetting": "Theme Setting"
"settingAppBar": "Setting",
"settingThemeSetting": "Theme Setting",
"settingAbout": "About FlutterMobileTemplate",
"settingOpenSourceLicenses": "Open source licenses",
"settingLibrariesWeUse": "Libraries we use"
}
7 changes: 5 additions & 2 deletions packages/features/setting/assets/l10n/app_ja.arb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"settingAppBar": "設定",
"settingThemeSetting": "テーマ設定"
"settingAppBar": "設定",
"settingThemeSetting": "テーマ設定",
"settingAbout": "FlutterMobileTemplate について",
"settingOpenSourceLicenses": "オープンソースライセンス",
"settingLibrariesWeUse": "使用しているライブラリ"
}
18 changes: 18 additions & 0 deletions packages/features/setting/lib/src/gen/l10n/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions packages/features/setting/lib/src/gen/l10n/l10n_en.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions packages/features/setting/lib/src/gen/l10n/l10n_ja.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/features/setting/lib/src/ui/components/index.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export 'setting_section_spacer.dart';
export 'setting_section_title.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:flutter/material.dart';

/// [SettingSectionSpacer] is a widget that represents the space for
/// each section of the settings screen.
final class SettingSectionSpacer extends StatelessWidget {
const SettingSectionSpacer({super.key});

@override
Widget build(BuildContext context) {
return const SliverPadding(
padding: EdgeInsets.only(
bottom: 16,
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'package:flutter/material.dart';

/// [SettingSectionTitle] is a widget that represents the section title of
/// the settings screen.
final class SettingSectionTitle extends StatelessWidget {
/// You can set the text to be displayed as the title in [text].
const SettingSectionTitle({
required String text,
super.key,
}) : _text = text;

final String _text;

@override
Widget build(BuildContext context) => SliverPadding(
padding: const EdgeInsets.symmetric(
vertical: 16,
horizontal: 24,
),
sliver: SliverToBoxAdapter(
child: Text(_text),
),
);
}
30 changes: 21 additions & 9 deletions packages/features/setting/lib/src/ui/setting_page.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'package:cores_data/theme_mode.dart';
import 'package:cores_navigation/providers.dart';
import 'package:features_setting/src/gen/l10n/l10n.dart';
import 'package:features_setting/src/ui/components/index.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

Expand All @@ -8,6 +10,7 @@ class SettingPage extends ConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
final navigator = ref.watch(settingNavigatorProvider);
final currentThemeMode = ref.watch(themeModeNotifierProvider);
final l10n = L10nSetting.of(context);

Expand All @@ -17,15 +20,7 @@ class SettingPage extends ConsumerWidget {
),
body: CustomScrollView(
slivers: [
SliverPadding(
padding: const EdgeInsets.symmetric(
vertical: 16,
horizontal: 24,
),
sliver: SliverToBoxAdapter(
child: Text(l10n.settingThemeSetting),
),
),
SettingSectionTitle(text: l10n.settingThemeSetting),
SliverList.builder(
itemCount: ThemeMode.values.length,
itemBuilder: (context, index) {
Expand All @@ -47,6 +42,23 @@ class SettingPage extends ConsumerWidget {
);
},
),
const SettingSectionSpacer(),
SettingSectionTitle(text: l10n.settingAbout),
SliverList(
delegate: SliverChildListDelegate(
[
ListTile(
contentPadding: const EdgeInsets.symmetric(
horizontal: 24,
),
leading: const Icon(Icons.description),
title: Text(l10n.settingOpenSourceLicenses),
subtitle: Text(l10n.settingLibrariesWeUse),
onTap: () => navigator.goLicensePage(context),
),
],
),
),
],
),
);
Expand Down
7 changes: 7 additions & 0 deletions packages/features/setting/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ packages:
relative: true
source: path
version: "0.0.1"
cores_navigation:
dependency: "direct main"
description:
path: "../../cores/navigation"
relative: true
source: path
version: "0.0.1"
dio:
dependency: transitive
description:
Expand Down
2 changes: 2 additions & 0 deletions packages/features/setting/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ environment:
dependencies:
cores_data:
path: ../../../packages/cores/data
cores_navigation:
path: ../../../packages/cores/navigation
flutter:
sdk: flutter
flutter_localizations:
Expand Down

0 comments on commit e488705

Please sign in to comment.