-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ElNgatia/refactor
refactor: migrate flutter gradle plugin apply
- Loading branch information
Showing
21 changed files
with
1,282 additions
and
350 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"flutter": "3.24.3" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"dart.flutterSdkPath": ".fvm/versions/3.24.3" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,25 @@ | ||
include ':app' | ||
pluginManagement { | ||
def flutterSdkPath = { | ||
def properties = new Properties() | ||
file("local.properties").withInputStream { properties.load(it) } | ||
def flutterSdkPath = properties.getProperty("flutter.sdk") | ||
assert flutterSdkPath != null, "flutter.sdk not set in local.properties" | ||
return flutterSdkPath | ||
}() | ||
|
||
def localPropertiesFile = new File(rootProject.projectDir, "local.properties") | ||
def properties = new Properties() | ||
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") | ||
|
||
assert localPropertiesFile.exists() | ||
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } | ||
repositories { | ||
google() | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
} | ||
|
||
def flutterSdkPath = properties.getProperty("flutter.sdk") | ||
assert flutterSdkPath != null, "flutter.sdk not set in local.properties" | ||
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" | ||
plugins { | ||
id "dev.flutter.flutter-plugin-loader" version "1.0.0" | ||
id "com.android.application" version "7.4.2" apply false | ||
id "org.jetbrains.kotlin.android" version "1.7.10" apply false | ||
} | ||
|
||
include ":app" |
27 changes: 27 additions & 0 deletions
27
lib/activity/data/datasource/activity_local_datasource.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'package:adventure_quest/database/app_database.dart'; | ||
|
||
abstract class ActivityLocalDataSource { | ||
// get activities, add activity, delete activity, | ||
Future<void> addActivity(activityCompanion); | ||
void deleteActivity(int id); | ||
Future<List<ActivityData>> getActivity(); | ||
} | ||
|
||
class ActivityLocalDataSourceImpl implements ActivityLocalDataSource { | ||
@override | ||
Future<void> addActivity(activityCompanion) { | ||
return appDatabase.into(appDatabase.activity).insert(activityCompanion); | ||
} | ||
|
||
@override | ||
Future<int> deleteActivity(int id) { | ||
return (appDatabase.delete(appDatabase.activity)..where((tbl) => tbl.id.equals(id))).go(); | ||
} | ||
|
||
@override | ||
Future<List<ActivityData>> getActivity() { | ||
return appDatabase.select(appDatabase.activity).get(); | ||
} | ||
} | ||
|
||
ActivityLocalDataSource activityLocalDataSource = ActivityLocalDataSourceImpl(); |
23 changes: 23 additions & 0 deletions
23
lib/activity/data/datasource/activity_remote_datasource.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:adventure_quest/database/app_database.dart'; | ||
import 'package:http/http.dart' as http; | ||
|
||
abstract class ActivityRemoteDataSource { | ||
Future<ActivityData> fetchActivity(); | ||
} | ||
|
||
class ActivityRemoteDataSourceImpl implements ActivityRemoteDataSource { | ||
@override | ||
Future<ActivityData> fetchActivity() async { | ||
try { | ||
final response = await http.get(Uri.parse('https://bored.api.lewagon.com/api/activity/')); | ||
|
||
return ActivityData.fromJson(json.decode(response.body)); | ||
} catch (e) { | ||
rethrow; | ||
} | ||
} | ||
} | ||
|
||
ActivityRemoteDataSource activityRemoteDataSource = ActivityRemoteDataSourceImpl(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import 'package:drift/drift.dart'; | ||
|
||
class Activity extends Table { | ||
IntColumn get id => integer().autoIncrement().nullable()(); | ||
TextColumn get activity => text()(); | ||
TextColumn get type => text()(); | ||
IntColumn get participants => integer()(); | ||
TextColumn get link => text()(); | ||
TextColumn get key => text().unique()(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import 'package:adventure_quest/activity/data/datasource/activity_local_datasource.dart'; | ||
import 'package:adventure_quest/activity/data/datasource/activity_remote_datasource.dart'; | ||
import 'package:adventure_quest/database/app_database.dart'; | ||
|
||
abstract class ActivityRepository { | ||
// fetch, get, delete, save, basic crud with api calls too | ||
Future<ActivityData> fetchActivity(); | ||
Future<List<ActivityData>> getActivity(); | ||
Future<void> saveActivity(activity); | ||
void deleteActivity(int id); | ||
} | ||
|
||
class ActivityRepositoryImpl implements ActivityRepository { | ||
@override | ||
void deleteActivity(int id) { | ||
return activityLocalDataSource.deleteActivity(id); | ||
} | ||
|
||
@override | ||
Future<ActivityData> fetchActivity() async { | ||
return activityRemoteDataSource.fetchActivity(); | ||
} | ||
|
||
@override | ||
Future<List<ActivityData>> getActivity() { | ||
return activityLocalDataSource.getActivity(); | ||
} | ||
|
||
@override | ||
Future<void> saveActivity(activityCompanion) async { | ||
return await activityLocalDataSource.addActivity(activityCompanion); | ||
} | ||
} | ||
|
||
ActivityRepository activityRepository = ActivityRepositoryImpl(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import '../presentation/common_scaffold.dart'; | ||
import 'config/color_schemes.g.dart'; | ||
|
||
class App extends StatelessWidget { | ||
const App({super.key}); | ||
|
||
// This widget is the root of your application. | ||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
debugShowCheckedModeBanner: false, | ||
title: 'Adventure Quest', | ||
theme: ThemeData( | ||
useMaterial3: true, | ||
colorScheme: lightColorScheme), | ||
darkTheme: ThemeData( | ||
useMaterial3: true, | ||
colorScheme: darkColorScheme), | ||
home: const CommonScaffold(), | ||
); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'package:drift/drift.dart'; | ||
|
||
import 'package:adventure_quest/activity/data/model/activity.dart'; | ||
import 'package:drift_flutter/drift_flutter.dart'; | ||
|
||
part 'app_database.g.dart'; | ||
|
||
@DriftDatabase(tables: [Activity]) | ||
class AppDatabase extends _$AppDatabase { | ||
AppDatabase() : super(_openDatabase()); | ||
|
||
@override | ||
int get schemaVersion => 1; | ||
|
||
@override | ||
MigrationStrategy get migration { | ||
return MigrationStrategy( | ||
onCreate: (m) async { | ||
await m.createAll(); | ||
}, | ||
onUpgrade: (m, from, to) async {}, | ||
); | ||
} | ||
|
||
static QueryExecutor _openDatabase() { | ||
return driftDatabase(name: 'adventure_quest'); | ||
} | ||
} | ||
|
||
AppDatabase appDatabase = AppDatabase(); |
Oops, something went wrong.