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

Drift #355

Merged
merged 6 commits into from
Apr 6, 2024
Merged

Drift #355

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: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

.PHONY: build-runner build-launcher-icons update-goldens

.PHONY: build-runner
build-runner:
test -e .env || cp .env_example .env
flutter pub get && dart run build_runner build -d && dart format -l 80 lib/i18n

.PHONY: build-launcher-icons
build-launcher-icons:
flutter pub run flutter_launcher_icons:main

.PHONY: update-goldens
update-goldens:
flutter test --update-goldens --tags=golden
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
| Tool | Version |
| -------------- | ------- |
| Flutter | 3.19.4 |
| Xcode | 15.2 |
| Xcode | 15.3 |
| Android Studio | |

# Architecture
Expand All @@ -38,7 +38,7 @@ graph LR;
- Store
- 状態の保持、主に NotifierProvier で実装
- State の更新は Service 経由で行う
- Presentation から watch することで状態をリアクティブにUIに反映させる
- Presentation から watch することで状態をリアクティブに UI に反映させる
- Service
- UI の操作に基づいて処理を行う
- 主に Repository に対する操作を行いデータを取得する
Expand All @@ -52,7 +52,7 @@ graph LR;
- DI
- [Riverpod(v2, generator)](https://riverpod.dev/)
- Data store
- [Isar Database](https://isar.dev/ja/)
- [Drift](https://drift.simonbinder.eu/)
- [shared_preferences](https://pub.dev/packages/shared_preferences)
- UI
- [youtube_player_flutter](https://pub.dev/packages/youtube_player_flutter)
Expand Down Expand Up @@ -88,13 +88,13 @@ graph LR;
- dev
- 開発用(ローカルビルド)
- リポジトリの一部をモックに差し替えている
- BundleID:dev.yorifuji.buzz_recipe_viewer.dev
- BundleID: dev.yorifuji.buzz_recipe_viewer.dev
- stg
- STG 配布(Firebase App Distribution)
- dev.yorifuji.buzz_recipe_viewer.stg
- BundleID: dev.yorifuji.buzz_recipe_viewer.stg
- prod
- 本番配布
- dev.yorifuji.buzz_recipe_viewer
- 本番配布(PlayConsole, TestFlight)
- BundleID: dev.yorifuji.buzz_recipe_viewer

# Test

Expand Down
9 changes: 9 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,12 @@ targets:
slang_build_runner:
options:
input_directory: lib/i18n
# drift_dev:
# options:
# sql:
# dialect: sqlite
# options:
# modules:
# - json1
# - fts5
# - math
29 changes: 22 additions & 7 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ PODS:
- flutter_inappwebview_ios/Core (0.0.1):
- Flutter
- OrderedSet (~> 5.0)
- isar_flutter_libs (1.0.0):
- Flutter
- OrderedSet (5.0.0)
- package_info_plus (0.4.5):
- Flutter
Expand All @@ -18,48 +16,65 @@ PODS:
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
- sqlite3 (3.45.1):
- sqlite3/common (= 3.45.1)
- sqlite3/common (3.45.1)
- sqlite3/fts5 (3.45.1):
- sqlite3/common
- sqlite3/perf-threadsafe (3.45.1):
- sqlite3/common
- sqlite3/rtree (3.45.1):
- sqlite3/common
- sqlite3_flutter_libs (0.0.1):
- Flutter
- sqlite3 (~> 3.45.1)
- sqlite3/fts5
- sqlite3/perf-threadsafe
- sqlite3/rtree
- url_launcher_ios (0.0.1):
- Flutter

DEPENDENCIES:
- Flutter (from `Flutter`)
- flutter_inappwebview_ios (from `.symlinks/plugins/flutter_inappwebview_ios/ios`)
- isar_flutter_libs (from `.symlinks/plugins/isar_flutter_libs/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sqlite3_flutter_libs (from `.symlinks/plugins/sqlite3_flutter_libs/ios`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)

SPEC REPOS:
trunk:
- OrderedSet
- sqlite3

EXTERNAL SOURCES:
Flutter:
:path: Flutter
flutter_inappwebview_ios:
:path: ".symlinks/plugins/flutter_inappwebview_ios/ios"
isar_flutter_libs:
:path: ".symlinks/plugins/isar_flutter_libs/ios"
package_info_plus:
:path: ".symlinks/plugins/package_info_plus/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
sqlite3_flutter_libs:
:path: ".symlinks/plugins/sqlite3_flutter_libs/ios"
url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios"

SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_inappwebview_ios: 97215cf7d4677db55df76782dbd2930c5e1c1ea0
isar_flutter_libs: b69f437aeab9c521821c3f376198c4371fa21073
OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c
package_info_plus: 58f0028419748fad15bf008b270aaa8e54380b1c
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
sqlite3: 73b7fc691fdc43277614250e04d183740cb15078
sqlite3_flutter_libs: af0e8fe9bce48abddd1ffdbbf839db0302d72d80
url_launcher_ios: 6116280ddcfe98ab8820085d8d76ae7449447586

PODFILE CHECKSUM: 0805b11bfb13bd44fc55fe52946ce14f22a2998e

COCOAPODS: 1.15.0
COCOAPODS: 1.15.2
2 changes: 1 addition & 1 deletion lib/i18n/strings.g.dart

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

20 changes: 4 additions & 16 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,39 +1,27 @@
import 'package:buzz_recipe_viewer/app.dart';
import 'package:buzz_recipe_viewer/model/isar/favorite.dart';
import 'package:buzz_recipe_viewer/model/isar/history.dart';
import 'package:buzz_recipe_viewer/model/isar/recipe_note.dart';
import 'package:buzz_recipe_viewer/provider/isar_provider.dart';
import 'package:buzz_recipe_viewer/provider/database_provider.dart';
import 'package:buzz_recipe_viewer/provider/package_info_provider.dart';
import 'package:buzz_recipe_viewer/provider/shared_preferences_provider.dart';
import 'package:buzz_recipe_viewer/repository/drift/database.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:isar/isar.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();

final (_, isar, packageInfo, sharedPreferences) = await (
// dotenv
final (_, packageInfo, sharedPreferences) = await (
dotenv.load(),
// Isar
Isar.open(
[HistorySchema, FavoriteSchema, RecipeNoteSchema],
directory: (await getApplicationDocumentsDirectory()).path,
),
// PackageInfo
PackageInfo.fromPlatform(),
// SharedPreferences
SharedPreferences.getInstance()
).wait;

runApp(
ProviderScope(
overrides: [
isarProvider.overrideWithValue(isar),
databaseProvider.overrideWithValue(AppDatabase()),
packageInfoProvider.overrideWithValue(packageInfo),
sharedPreferencesProvider.overrideWithValue(sharedPreferences),
],
Expand Down
23 changes: 23 additions & 0 deletions lib/model/favorite.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:buzz_recipe_viewer/model/search_hit.dart';
import 'package:freezed_annotation/freezed_annotation.dart';

part 'favorite.freezed.dart';

@freezed
class Favorite with _$Favorite {
const factory Favorite({
required SearchHit searchHit,
required DateTime createdAt,
required DateTime updatedAt,
int? id,
}) = _Favorite;

factory Favorite.from(SearchHit searchHit) {
final now = DateTime.now();
return Favorite(
searchHit: searchHit,
createdAt: now,
updatedAt: now,
);
}
}
Loading