Skip to content

Commit b905b99

Browse files
authored
Merge pull request #23 from tmaxxdd/refactor/increase-code-consistency
Added release config
2 parents eb0b8c5 + c8dd1ad commit b905b99

File tree

8 files changed

+102
-100
lines changed

8 files changed

+102
-100
lines changed

app/build.gradle

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ def STRING = "String"
1212
android {
1313
compileSdk 33
1414

15+
signingConfigs {
16+
release {
17+
storeFile file("../debug.keystore")
18+
storePassword "android"
19+
keyAlias "androiddebugkey"
20+
keyPassword "android"
21+
}
22+
}
23+
1524
defaultConfig {
1625
applicationId "pl.tkadziolka.snipmeandroid"
1726
minSdk 21
@@ -32,6 +41,14 @@ android {
3241

3342
buildConfigField STRING, BASE_URL, API_BASE_URL
3443
}
44+
45+
release {
46+
minifyEnabled true
47+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
48+
signingConfig signingConfigs.release
49+
50+
buildConfigField STRING, BASE_URL, API_BASE_URL
51+
}
3552
}
3653

3754
compileOptions {

app/src/main/java/pl/tkadziolka/snipmeandroid/MainActivity.kt

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,16 @@ class MainActivity : AppCompatActivity() {
1919
super.onCreate(savedInstanceState)
2020
setContentView(R.layout.activity_main)
2121

22-
// Instantiate a FlutterEngine.
23-
flutterEngine = FlutterEngine(this)
24-
25-
// Start executing Dart code to pre-warm the FlutterEngine.
26-
flutterEngine.dartExecutor.executeDartEntrypoint(
27-
DartExecutor.DartEntrypoint.createDefault()
28-
)
29-
30-
flutterEngine.plugins.add(LoginModelPlugin())
31-
flutterEngine.plugins.add(MainModelPlugin())
32-
flutterEngine.plugins.add(DetailModelPlugin())
33-
34-
// Cache the FlutterEngine to be used by FlutterActivity.
35-
FlutterEngineCache
36-
.getInstance()
37-
.put(cachedEngineId, flutterEngine)
38-
39-
startActivity(
40-
FlutterActivity
41-
.withCachedEngine(cachedEngineId)
42-
.build(this)
43-
)
22+
FlutterEngine(this).apply {
23+
dartExecutor.executeDartEntrypoint(DartExecutor.DartEntrypoint.createDefault())
24+
25+
plugins.add(LoginModelPlugin())
26+
plugins.add(MainModelPlugin())
27+
plugins.add(DetailModelPlugin())
28+
29+
FlutterEngineCache.getInstance().put(cachedEngineId, this)
30+
31+
startActivity(FlutterActivity.withCachedEngine(cachedEngineId).build(baseContext))
32+
}
4433
}
4534
}

app/src/main/java/pl/tkadziolka/snipmeandroid/di/NetworkModule.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ internal val networkModule = module {
6363

6464
single<Retrofit> {
6565
Retrofit.Builder()
66-
.client(get())
66+
.client(get<OkHttpClient>())
6767
.baseUrl(BuildConfig.BASE_URL)
6868
.addConverterFactory(MoshiConverterFactory.create())
6969
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())

app/src/main/java/pl/tkadziolka/snipmeandroid/infrastructure/local/AuthPreferences.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import pl.tkadziolka.snipmeandroid.util.PreferencesUtil
55
private const val TOKEN_KEY = "7e3a40ea-32d2-4248-bcfb-297f2f41246e"
66

77
class AuthPreferences(private val prefs: PreferencesUtil) {
8-
98
fun saveToken(token: String) {
109
prefs.save(TOKEN_KEY, token)
1110
}

debug.keystore

2.42 KB
Binary file not shown.

flutter_module/lib/presentation/navigation/login/login_navigator.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import 'package:flutter/foundation.dart';
22
import 'package:flutter_module/presentation/navigation/screen_navigator.dart';
33
import 'package:go_router_plus/go_router_plus.dart';
44

5-
class LoginNavigator extends ScreenNavigator
6-
with ChangeNotifier
7-
implements LoggedInState {
5+
class LoginNavigator extends ScreenNavigator with ChangeNotifier implements LoggedInState {
86
bool _loggedIn = false;
97

108
@override

flutter_module/lib/presentation/widgets/snippet_list_item.dart

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,44 +24,40 @@ class SnippetListTile extends HookWidget {
2424
Widget build(BuildContext context) {
2525
return SurfaceStyles.snippetCard(
2626
onTap: onTap,
27-
child: Expanded(
28-
child: Column(
29-
crossAxisAlignment: CrossAxisAlignment.stretch,
30-
children: [
31-
Padding(
32-
padding: const EdgeInsets.only(
33-
top: Dimens.l,
34-
left: Dimens.l,
35-
right: Dimens.l,
36-
bottom: Dimens.m,
37-
),
38-
child: TextStyles.title(snippet.title ?? ""),
27+
child: Column(
28+
crossAxisAlignment: CrossAxisAlignment.stretch,
29+
children: [
30+
Padding(
31+
padding: const EdgeInsets.only(
32+
top: Dimens.l,
33+
left: Dimens.l,
34+
right: Dimens.l,
35+
bottom: Dimens.m,
3936
),
40-
Ink(
41-
color: ColorStyles.codeBackground(),
42-
child: Padding(
43-
padding: const EdgeInsets.symmetric(
44-
vertical: Dimens.m,
45-
horizontal: Dimens.l,
46-
),
47-
child: Expanded(
48-
child: CodeTextView.preview(
49-
code: snippet.code?.raw ?? "",
50-
tokens: snippet.code?.tokens,
51-
),
52-
),
37+
child: TextStyles.title(snippet.title ?? ""),
38+
),
39+
Ink(
40+
color: ColorStyles.codeBackground(),
41+
child: Padding(
42+
padding: const EdgeInsets.symmetric(
43+
vertical: Dimens.m,
44+
horizontal: Dimens.l,
45+
),
46+
child: CodeTextView.preview(
47+
code: snippet.code?.raw ?? "",
48+
tokens: snippet.code?.tokens,
5349
),
5450
),
51+
),
52+
const SizedBox(height: Dimens.m),
53+
if (isExpanded) ...[
54+
Padding(
55+
padding: const EdgeInsets.symmetric(horizontal: Dimens.l),
56+
child: SnippetDetailsBar(snippet: snippet),
57+
),
5558
const SizedBox(height: Dimens.m),
56-
if (isExpanded) ...[
57-
Padding(
58-
padding: const EdgeInsets.symmetric(horizontal: Dimens.l),
59-
child: SnippetDetailsBar(snippet: snippet),
60-
),
61-
const SizedBox(height: Dimens.m),
62-
],
6359
],
64-
),
60+
],
6561
),
6662
);
6763
}

flutter_module/lib/presentation/widgets/view_state_wrapper.dart

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,48 @@ import 'package:flutter/material.dart';
22

33
typedef DataWidgetBuilder<T> = Widget Function(BuildContext context, T? data);
44

5-
class ViewStateWrapper<T> extends StatelessWidget {
6-
const ViewStateWrapper({
7-
Key? key,
8-
required this.builder,
9-
this.isLoading = false,
10-
this.data,
11-
this.error,
12-
}) : super(key: key);
5+
class ViewStateWrapper<T> extends StatelessWidget {
6+
const ViewStateWrapper({
7+
Key? key,
8+
required this.builder,
9+
this.isLoading = false,
10+
this.data,
11+
this.error,
12+
}) : super(key: key);
1313

14-
final bool isLoading;
15-
final T? data;
16-
final String? error;
17-
final DataWidgetBuilder<T> builder;
14+
final bool isLoading;
15+
final T? data;
16+
final String? error;
17+
final DataWidgetBuilder<T> builder;
1818

19-
@override
20-
Widget build(BuildContext context) {
21-
return Stack(
22-
children: [
23-
// Data
24-
Visibility(
25-
visible: error == null && !isLoading,
26-
child: builder.call(context, data),
27-
),
28-
// Loading
29-
Visibility(
30-
visible: isLoading,
31-
child: const Center(child: CircularProgressIndicator()),
32-
),
33-
// Error
34-
Visibility(
35-
visible: error != null,
36-
child: Center(
37-
child: Column(
38-
mainAxisSize: MainAxisSize.min,
39-
children: [const Text("Error"), Text(error ?? "")],
40-
),
41-
),
42-
)
43-
],
44-
);
45-
}
46-
}
19+
@override
20+
Widget build(BuildContext context) {
21+
return Stack(
22+
children: [
23+
// Data
24+
Visibility(
25+
visible: error == null && !isLoading,
26+
child: builder.call(context, data),
27+
),
28+
// Loading
29+
Visibility(
30+
visible: isLoading,
31+
child: const Center(child: CircularProgressIndicator()),
32+
),
33+
// Error
34+
Visibility(
35+
visible: error != null,
36+
child: Center(
37+
child: Column(
38+
mainAxisSize: MainAxisSize.min,
39+
children: [
40+
const Text("Error"),
41+
Text(error ?? ""),
42+
],
43+
),
44+
),
45+
)
46+
],
47+
);
48+
}
49+
}

0 commit comments

Comments
 (0)