Skip to content

Commit d8a8591

Browse files
committed
Added the missing alerts
1 parent 6bf3ce3 commit d8a8591

23 files changed

+459
-160
lines changed

android/app/build.gradle

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,25 @@ if (flutterVersionName == null) {
2222
}
2323

2424
apply plugin: 'com.android.application'
25+
apply plugin: 'kotlin-android'
2526
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2627

2728
android {
28-
compileSdkVersion 31
29+
compileSdkVersion flutter.compileSdkVersion
30+
ndkVersion flutter.ndkVersion
31+
32+
compileOptions {
33+
sourceCompatibility JavaVersion.VERSION_1_8
34+
targetCompatibility JavaVersion.VERSION_1_8
35+
}
2936

3037
defaultConfig {
3138
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
32-
applicationId "com.example.spice"
33-
minSdkVersion 17
34-
targetSdkVersion 31
39+
applicationId "com.example.untitled1"
40+
// You can update the following values to match your application needs.
41+
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
42+
minSdkVersion flutter.minSdkVersion
43+
targetSdkVersion flutter.targetSdkVersion
3544
versionCode flutterVersionCode.toInteger()
3645
versionName flutterVersionName
3746
}

android/app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,23 @@
77
</intent>
88
</queries>
99
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
10-
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
10+
<!-- <uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
11+
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />-->
12+
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION"/>
1113
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
1214
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
1315
<uses-permission android:name="android.permission.INTERNET" />
1416
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
15-
<uses-permission android:name="android.permission.MANAGE_INTERNAL_STORAGE" />
17+
<uses-permission android:name="android.permission.MANAGE_INTERNAL_STORAGE"/>
1618

1719
<application
1820
android:label="spice"
1921
android:icon="@mipmap/ic_launcher"
20-
android:requestLegacyExternalStorage="true"
21-
android:allowBackup="false">
22+
android:name="${applicationName}"
23+
android:requestLegacyExternalStorage="true">
2224
<activity
2325
android:name=".MainActivity"
26+
android:exported="true"
2427
android:launchMode="singleTop"
2528
android:theme="@style/LaunchTheme"
2629
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"

android/build.gradle

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
buildscript {
2+
ext.kotlin_version = '1.6.10'
23
repositories {
34
google()
4-
jcenter()
5+
mavenCentral()
56
}
67

78
dependencies {
8-
classpath 'com.android.tools.build:gradle:4.1.0'
9+
classpath 'com.android.tools.build:gradle:7.1.2'
10+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
911
}
1012
}
1113

1214
allprojects {
1315
repositories {
1416
google()
15-
jcenter()
17+
mavenCentral()
1618
}
1719
}
1820

1921
rootProject.buildDir = '../build'
2022
subprojects {
2123
project.buildDir = "${rootProject.buildDir}/${project.name}"
24+
}
25+
subprojects {
2226
project.evaluationDependsOn(':app')
2327
}
2428

android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip

lib/controllers/language_controller.dart

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import 'package:get_storage/get_storage.dart';
44
class LanguageController extends GetxController {
55
bool isHungarian = true;
66

7-
//todo: a loating action button tooltipek hozzáadása
8-
97
//language screen
108
String get languageHeader => (isHungarian) ? "Nyelv beállítása" : "Languages";
119
String get languageDescription => (isHungarian)
@@ -17,14 +15,14 @@ class LanguageController extends GetxController {
1715
//home screen
1816
String get homeHeader1 => (isHungarian) ? "Gyors elérés" : "Quick access";
1917
String get homeDescription1 => (isHungarian)
20-
? "Lehetővé teszi a termék gyors elérést. A lista módosításához kattints a szerkesztés gombra."
21-
: "Allows quick access to the product. To edit the list, click on the edit button.";
18+
? "Lehetővé teszi a termékeknek a gyors elérését a főoldalon. A lista módosításához kattints a szerkesztés gombra."
19+
: "Allows quick access to products on the main page. To edit the list, click on the edit button.";
2220
String get homeButton1 => (isHungarian) ? "szerkesztés" : "edit";
2321
String get homeHeader2 =>
2422
(isHungarian) ? "További lehetőségek" : "Other options";
2523
String get homeDescription2 => (isHungarian)
26-
? "Itt találja meg az applikáció fő menüpontjait."
27-
: "Here you can find the main menu options of the app.";
24+
? "Itt található az applikáció fő menüpontjai"
25+
: "Here are the main menus of the app.";
2826
String get homeButton2 =>
2927
(isHungarian) ? "Fűszer kimérése" : "Spice weighing";
3028
String get homeButton3 => (isHungarian) ? "Termékek" : "Products";
@@ -86,7 +84,7 @@ class LanguageController extends GetxController {
8684

8785
//spice edit screen
8886
String get spiceEditHeader1 =>
89-
(isHungarian) ? "fűszer szerkesztése" : "edit spice";
87+
(isHungarian) ? "Fűszer szerkesztése" : "Edit spice";
9088
String get spiceEditToolTip1 =>
9189
(isHungarian) ? "fűszer törlése" : "felete spice";
9290
String get spiceEditToolTip2 => (isHungarian) ? "módosítás" : "save changes";
@@ -114,8 +112,8 @@ class LanguageController extends GetxController {
114112
(isHungarian) ? "Mentés az eszközre" : "Save to device";
115113
String get dataHeader4 => (isHungarian) ? "Adatok törlése" : "Delete data";
116114
String get dataDescription3 => (isHungarian)
117-
? "Az alábbi gombra kattintva az adatok véglegesen törlődni fognak a készülékről."
118-
: "Clicking the button below will permanently delete the data from your device.";
115+
? "Az alábbi gombra kattintva az adatok véglegesen törlődni fognak a készülékről. Az adatokról érdemes biztonségi mentést készíteni mielőtt törölné, hogy azt később vissza lehessen állítani."
116+
: "Clicking the button below will permanently delete the data from your device. You should make a backup of your data before you delete it so that you can restore it later.";
119117
String get dataButton3 => (isHungarian) ? "Adatok törlése" : "Delete data";
120118

121119
//no
@@ -125,6 +123,55 @@ class LanguageController extends GetxController {
125123
//other
126124
String get otherBack => (isHungarian) ? "vissza" : "back";
127125

126+
//alert
127+
String get alertClose => (isHungarian) ? "Bezár" : "Close";
128+
String get alertError => (isHungarian) ? "Hiba" : "Error";
129+
String get alertProductNameEmpty => (isHungarian)
130+
? "A termék megnevezése nem lehet üres."
131+
: "The name of product can't be empty.";
132+
String get alertProductQuantityEmpty => (isHungarian)
133+
? "A termék mennyisége nem lehet üres."
134+
: "The quantity of product can't be empty.";
135+
String get alertProductQuantityNaN => (isHungarian)
136+
? "A termék mennyisége csak számot tartalmazhat."
137+
: "The quantity of the product can only contain a number.";
138+
String get alertSpiceNameEmpty => (isHungarian)
139+
? "A fűszer megnevezése nem lehet üres."
140+
: "The name of spice can't be empty.";
141+
String get alertSpiceQuantityEmpty => (isHungarian)
142+
? "A fűszer mennyisége nem lehet üres."
143+
: "The quantity of spice can't be empty.";
144+
String get alertSpiceQuantityNaN => (isHungarian)
145+
? "A fűszer mennyisége csak számot tartalmazhat."
146+
: "The quantity of the spice can only contain a number.";
147+
String get alertDelete => (isHungarian) ? "Adatok törlése" : "Delete Data";
148+
String get alertSpiceDeleteTitle =>
149+
(isHungarian) ? "Fűszer törlése" : "Delete Spice";
150+
String get alertProductDeleteTitle =>
151+
(isHungarian) ? "Termék törlése" : "Delete Product";
152+
String get alertYes => (isHungarian) ? "Igen" : "Confirm";
153+
String get alertNo => (isHungarian) ? "Nem" : "Chanel";
154+
String get alertProductDelete => (isHungarian)
155+
? "Biztos törölni akarja ezt a terméket?"
156+
: "Are you sure you want to remove this product?";
157+
String get alertSpiceDelete => (isHungarian)
158+
? "Biztos törölni akarja ezt a fűszert a termék fűszer listájából?"
159+
: "Are you sure you want to remove this spice from the spice list of the product?";
160+
String get alertDataDelete => (isHungarian)
161+
? "Biztos törölni akarja adatait a készülékről?"
162+
: "Are you sure you want to delete your data from your device?";
163+
164+
//snack bar
165+
String get snackBarDelete =>
166+
(isHungarian) ? 'Az adatok törlődtek.' : 'The data has been deleted.';
167+
String get snackBarBackup1 => (isHungarian)
168+
? "Az adatok a következő mappába kerültek mentésre."
169+
: "The data is saved in the following folder.";
170+
String get snackBarBackup2 =>
171+
(isHungarian) ? "Nincs menthető adat." : "No data to save.";
172+
String get snackBarRestore =>
173+
(isHungarian) ? "Sikeresen helyreállítva." : 'Restored successfully.';
174+
128175
final _box = GetStorage();
129176

130177
changeLanguage({required bool isHungarian}) {

lib/controllers/product_controller.dart

Lines changed: 51 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import 'dart:io';
44
import 'package:file_picker/file_picker.dart';
55
import 'package:flutter/material.dart';
66
import 'package:get/get.dart';
7-
import 'package:hive/hive.dart';
7+
import 'package:permission_handler/permission_handler.dart';
88
import 'package:spice/models/product.dart';
9+
import 'package:hive_flutter/hive_flutter.dart';
910

1011
class ProductController extends GetxController {
1112
final Box _box = Hive.box<Product>('products');
@@ -20,7 +21,6 @@ class ProductController extends GetxController {
2021
}
2122

2223
updateProduct({required int key, required Product product}) {
23-
print("update: ${product.key} ${product.name}");
2424
_box.put(key, product);
2525
update();
2626
}
@@ -30,82 +30,73 @@ class ProductController extends GetxController {
3030
update();
3131
}
3232

33-
Future delete() async {
33+
Future delete(BuildContext context, String delete) async {
3434
isDeleteInProgress = true;
3535
update();
3636
var result = await Future.delayed(Duration(milliseconds: 500), () async {
3737
var value = await _box.clear();
38-
print(">>> deleted value: $value");
3938
isDeleteInProgress = false;
4039
update();
4140
return value;
4241
});
43-
return result; //ha nulla vagy nagyobb akk sikeres
42+
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(delete)));
43+
return result;
4444
}
4545

46-
Future<void> makingBackup(BuildContext context) async {
47-
/*Directory? selectedDirectory = await FolderPicker.pick(
48-
allowFolderCreation: true,
49-
context: context,
50-
rootDirectory: Directory(FolderPicker.rootPath),
51-
shape: RoundedRectangleBorder(
52-
borderRadius: BorderRadius.all(Radius.circular(10))));*/
46+
Future<void> makingBackup(
47+
BuildContext context, String backup1, String backup2) async {
5348
if (_box.length != 0) {
54-
String? selected = await FilePicker.platform.getDirectoryPath();
55-
print(selected);
56-
if (selected != null) {
57-
Directory selectedDirectory = Directory(selected);
58-
59-
Map<String, Product> map =
60-
_box.toMap().map((key, value) => MapEntry(key.toString(), value));
61-
String json = JsonEncoder().convert(map);
62-
print(json);
63-
Directory dir = selectedDirectory;
64-
String formattedDate = DateTime.now()
65-
.toString()
66-
.replaceAll('.', '-')
67-
.replaceAll(' ', '-')
68-
.replaceAll(':', '-');
69-
await File('${dir.path}/$formattedDate.json').writeAsString(json);
70-
ScaffoldMessenger.of(context).showSnackBar(
71-
const SnackBar(content: Text('Backup saved in folder Passman')),
72-
);
49+
Map<Permission, PermissionStatus> statuses = await [
50+
Permission.storage,
51+
].request();
52+
53+
if (statuses[Permission.storage] == PermissionStatus.granted) {
54+
String? selected = await FilePicker.platform.getDirectoryPath();
55+
56+
if (selected != null) {
57+
Directory selectedDirectory = Directory(selected);
58+
59+
Map<String, Product> map =
60+
_box.toMap().map((key, value) => MapEntry(key.toString(), value));
61+
String json = JsonEncoder().convert(map);
62+
print(json);
63+
Directory dir = selectedDirectory;
64+
String formattedDate = DateTime.now()
65+
.toString()
66+
.replaceAll('.', '-')
67+
.replaceAll(' ', '-')
68+
.replaceAll(':', '-');
69+
await File('${dir.path}/$formattedDate.json').writeAsString(json);
70+
ScaffoldMessenger.of(context)
71+
.showSnackBar(SnackBar(content: Text('$backup1: $selected')));
72+
}
7373
}
7474
} else {
75-
ScaffoldMessenger.of(context).showSnackBar(
76-
const SnackBar(content: Text('Nincs adat')),
77-
);
75+
ScaffoldMessenger.of(context)
76+
.showSnackBar(SnackBar(content: Text(backup2)));
7877
}
7978
}
8079

81-
restore(BuildContext context) async {
82-
FilePickerResult? result = await FilePicker.platform.pickFiles();
83-
if (result != null) {
84-
File file = File(result.files.first.path!);
85-
_box.clear();
86-
Map<String, dynamic> map = jsonDecode(await file.readAsString());
87-
for (var i in map.entries) {
88-
print(i);
89-
_box.add(Product.fromJson(i.value));
90-
}
80+
restore(BuildContext context, String restore) async {
81+
Map<Permission, PermissionStatus> statuses = await [
82+
Permission.storage,
83+
].request();
84+
if (statuses[Permission.storage] == PermissionStatus.granted) {
85+
FilePickerResult? result = await FilePicker.platform.pickFiles();
86+
if (result != null) {
87+
File file = File(result.files.first.path!);
88+
_box.clear();
89+
Map<String, dynamic> map = jsonDecode(await file.readAsString());
90+
for (var i in map.entries) {
91+
print(i);
92+
_box.add(Product.fromJson(i.value));
93+
}
9194

92-
ScaffoldMessenger.of(context).showSnackBar(
93-
const SnackBar(content: Text('Restored Successfully...')),
94-
);
95+
ScaffoldMessenger.of(context)
96+
.showSnackBar(SnackBar(content: Text(restore)));
97+
}
98+
update();
9599
}
96-
/* final Directory rootPath = Directory("/storage/emulated/0/");
97-
String? path = await FilesystemPicker.open(
98-
title: 'Save to folder',
99-
context: context,
100-
rootDirectory: rootPath,
101-
fsType: FilesystemType.folder,
102-
pickText: 'Save file to this folder',
103-
contextActions: [
104-
FilesystemPickerNewFolderContextAction(),
105-
],
106-
);
107-
print(path);*/
108-
update();
109100
}
110101

111102
deleteAll() {

lib/global.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:spice/controllers/language_controller.dart';
22
import 'package:spice/controllers/quantity_controller.dart';
3-
import 'package:spice/screens/language/language_screen.dart';
43

54
import 'controllers/color_controller.dart';
65
import 'package:get/get.dart';

lib/main.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:get/get.dart';
33
import 'package:get_storage/get_storage.dart';
4-
import 'package:hive/hive.dart';
54
import 'package:hive_flutter/hive_flutter.dart';
65
import 'package:sizer/sizer.dart';
76
import 'package:spice/models/spice.dart';

lib/models/product.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import 'dart:convert';
2-
31
import 'package:spice/models/spice.dart';
42
import 'package:hive/hive.dart';
53

0 commit comments

Comments
 (0)