Skip to content

Commit 72ba8cc

Browse files
authored
Merge pull request #9 from ngomile/main
Add JobsListBloc and Perform Various Changes to Logic
2 parents f5537a9 + f20730c commit 72ba8cc

25 files changed

+416
-411
lines changed

android/app/build.gradle

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
plugins {
2+
id "com.android.application"
3+
id "kotlin-android"
4+
id "dev.flutter.flutter-gradle-plugin"
5+
}
6+
17
def localProperties = new Properties()
28
def localPropertiesFile = rootProject.file('local.properties')
39
if (localPropertiesFile.exists()) {
@@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
612
}
713
}
814

9-
def flutterRoot = localProperties.getProperty('flutter.sdk')
10-
if (flutterRoot == null) {
11-
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12-
}
13-
1415
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
1516
if (flutterVersionCode == null) {
1617
flutterVersionCode = '1'
@@ -21,18 +22,9 @@ if (flutterVersionName == null) {
2122
flutterVersionName = '1.0'
2223
}
2324

24-
apply plugin: 'com.android.application'
25-
apply plugin: 'kotlin-android'
26-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27-
28-
def keystoreProperties = new Properties()
29-
def keystorePropertiesFile = rootProject.file('key.properties')
30-
if (keystorePropertiesFile.exists()) {
31-
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
32-
}
33-
3425
android {
35-
compileSdkVersion 34
26+
namespace "com.doreanbyte.katswiri"
27+
compileSdkVersion flutter.compileSdkVersion
3628
ndkVersion flutter.ndkVersion
3729

3830
compileOptions {
@@ -49,37 +41,20 @@ android {
4941
}
5042

5143
defaultConfig {
52-
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
5344
applicationId "com.doreanbyte.katswiri"
54-
// You can update the following values to match your application needs.
55-
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
56-
minSdkVersion 19
45+
minSdkVersion flutter.minSdkVersion
5746
targetSdkVersion flutter.targetSdkVersion
5847
versionCode flutterVersionCode.toInteger()
5948
versionName flutterVersionName
6049
}
6150

62-
signingConfigs {
63-
release {
64-
keyAlias keystoreProperties['keyAlias']
65-
keyPassword keystoreProperties['keyPassword']
66-
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
67-
storePassword keystoreProperties['storePassword']
68-
}
69-
}
70-
71-
buildTypes {
72-
release {
73-
signingConfig signingConfigs.release
74-
}
75-
}
76-
51+
buildTypes {
52+
release {
53+
signingConfig signingConfigs.debug
54+
}
55+
}
7756
}
7857

7958
flutter {
8059
source '../..'
8160
}
82-
83-
dependencies {
84-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
85-
}

android/build.gradle

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
buildscript {
2-
ext.kotlin_version = '1.8.22'
3-
repositories {
4-
google()
5-
mavenCentral()
6-
}
7-
8-
dependencies {
9-
classpath 'com.android.tools.build:gradle:7.1.2'
10-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11-
}
12-
}
13-
141
allprojects {
152
repositories {
163
google()

android/settings.gradle

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1-
include ':app'
1+
pluginManagement {
2+
def flutterSdkPath = {
3+
def properties = new Properties()
4+
file("local.properties").withInputStream { properties.load(it) }
5+
def flutterSdkPath = properties.getProperty("flutter.sdk")
6+
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
7+
return flutterSdkPath
8+
}()
29

3-
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4-
def properties = new Properties()
10+
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
511

6-
assert localPropertiesFile.exists()
7-
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
12+
repositories {
13+
google()
14+
mavenCentral()
15+
gradlePluginPortal()
16+
}
17+
}
818

9-
def flutterSdkPath = properties.getProperty("flutter.sdk")
10-
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11-
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
19+
plugins {
20+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21+
id "com.android.application" version "7.1.2" apply false
22+
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
23+
}
24+
25+
include ":app"

devtools_options.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
description: This file stores settings for Dart & Flutter DevTools.
2+
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
3+
extensions:

lib/app_theme.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ ThemeData buildTheme({ColorScheme? scheme, required Brightness brightness}) {
2727
final isDark = brightness == Brightness.dark;
2828
final defScheme = isDark ? darkScheme : lightScheme;
2929
final colorScheme = scheme?.harmonized() ?? defScheme;
30-
final origin = isDark ? ThemeData.dark() : ThemeData.light();
30+
final origin = isDark
31+
? ThemeData.dark(useMaterial3: true)
32+
: ThemeData.light(useMaterial3: true);
3133

3234
return origin.copyWith(
33-
useMaterial3: true,
34-
colorScheme: colorScheme.copyWith(background: colorScheme.surface),
35+
colorScheme: colorScheme.copyWith(surface: colorScheme.surface),
3536
scaffoldBackgroundColor: isDark ? Colors.black87 : const Color(0xFFF2F2F2),
3637
tabBarTheme: origin.tabBarTheme.copyWith(
3738
unselectedLabelColor: isDark ? Colors.white70 : Colors.black54,

lib/bloc/bloc.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export 'saved_jobs_bloc/saved_jobs_bloc.dart';
33
export 'save_job_bloc/save_job_bloc.dart';
44
export 'job_description_bloc/job_description_bloc.dart';
55
export 'theme_bloc/theme_bloc.dart';
6+
export 'jobs_list_bloc/jobs_list_bloc.dart';
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
library job_list_bloc;
2+
3+
import 'package:flutter_bloc/flutter_bloc.dart';
4+
import 'package:katswiri/models/models.dart';
5+
import 'package:katswiri/sources/sources.dart';
6+
7+
part 'jobs_list_event.dart';
8+
part 'jobs_list_state.dart';
9+
10+
final class JobsListBloc extends Bloc<JobsListEvent, JobsListState> {
11+
final List<Job> _jobs = [];
12+
final Source _source;
13+
int _page = 1;
14+
15+
JobsListBloc({required Source source})
16+
: _source = source,
17+
super(const JobsListLoading(jobs: [])) {
18+
on<FetchJobs>((event, emit) async {
19+
try {
20+
emit(JobsListLoading(jobs: _jobs));
21+
final jobs = await _getJobs(filter: event.filter);
22+
23+
_jobs.addAll(jobs);
24+
emit(JobsListLoaded(jobs: _jobs));
25+
} on Exception catch (e) {
26+
emit(JobsListError(
27+
jobs: _jobs,
28+
error: e.toString(),
29+
));
30+
}
31+
});
32+
33+
on<RefreshJobs>((event, emit) async {
34+
try {
35+
_jobs.clear();
36+
_page = 1;
37+
emit(JobsListLoading(jobs: _jobs));
38+
39+
final jobs = await _getJobs(filter: event.filter);
40+
_jobs.addAll(jobs);
41+
emit(JobsListLoaded(jobs: _jobs));
42+
} on Exception catch (e) {
43+
emit(JobsListError(jobs: _jobs, error: e.toString()));
44+
}
45+
});
46+
}
47+
48+
Future<List<Job>> _getJobs({Map<String, String>? filter}) async {
49+
final jobs = await _source.fetchJobs(
50+
page: _page,
51+
filter: filter,
52+
);
53+
_page++;
54+
55+
return jobs;
56+
}
57+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
part of 'jobs_list_bloc.dart';
2+
3+
sealed class JobsListEvent {
4+
const JobsListEvent();
5+
}
6+
7+
final class FetchJobs extends JobsListEvent {
8+
const FetchJobs({this.filter});
9+
10+
final Map<String, String>? filter;
11+
}
12+
13+
final class RefreshJobs extends JobsListEvent {
14+
const RefreshJobs({this.filter});
15+
16+
final Map<String, String>? filter;
17+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
part of 'jobs_list_bloc.dart';
2+
3+
sealed class JobsListState {
4+
const JobsListState();
5+
}
6+
7+
final class JobsListLoading extends JobsListState {
8+
const JobsListLoading({required this.jobs});
9+
10+
final List<Job> jobs;
11+
}
12+
13+
final class JobsListLoaded extends JobsListState {
14+
const JobsListLoaded({required this.jobs});
15+
16+
final List<Job> jobs;
17+
}
18+
19+
final class JobsListError extends JobsListState {
20+
const JobsListError({
21+
required this.jobs,
22+
required this.error,
23+
});
24+
25+
final List<Job> jobs;
26+
final String error;
27+
}

lib/components/components.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
33
import 'package:katswiri/app_theme.dart';
44

55
export 'job_model_widgets.dart';
6-
export 'job_list_retriever.dart';
6+
export 'job_listings.dart';
77
export 'tabbed_sources.dart';
88
export 'button_widgets.dart';
99

0 commit comments

Comments
 (0)