Skip to content

Commit 4967f74

Browse files
authored
Merge pull request #367 from BrawlerXull/morelanguages
Add support for more languages
2 parents 31e1904 + 06abb3e commit 4967f74

17 files changed

+1239
-28
lines changed
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import 'package:get/get.dart';
2+
import 'package:taskwarrior/app/utils/language/supported_language.dart';
3+
import 'package:taskwarrior/app/utils/theme/app_settings.dart';
24

35
class AboutController extends GetxController {
4-
//TODO: Implement AboutController
6+
final Rx<SupportedLanguage> selectedLanguage = SupportedLanguage.english.obs;
57

6-
final count = 0.obs;
8+
@override
9+
void onInit() {
10+
super.onInit();
11+
initLanguage();
12+
}
713

8-
9-
10-
void increment() => count.value++;
14+
void initLanguage() {
15+
selectedLanguage.value = AppSettings.selectedLanguage;
16+
}
1117
}

lib/app/modules/about/views/about_page_app_bar.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
import 'package:flutter/material.dart';
2+
import 'package:taskwarrior/app/modules/about/controllers/about_controller.dart';
23

34

45
import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart';
56
import 'package:taskwarrior/app/utils/gen/fonts.gen.dart';
7+
import 'package:taskwarrior/app/utils/language/sentence_manager.dart';
68

79
class AboutPageAppBar extends StatelessWidget implements PreferredSizeWidget {
8-
const AboutPageAppBar({super.key});
10+
final AboutController aboutController;
11+
const AboutPageAppBar({required this.aboutController,super.key});
912

1013
@override
1114
Widget build(BuildContext context) {
1215
return AppBar(
1316
centerTitle: true,
1417
backgroundColor: TaskWarriorColors.kprimaryBackgroundColor,
1518
title: Text(
16-
'About',
19+
SentenceManager(
20+
currentLanguage: aboutController.selectedLanguage.value)
21+
.sentences
22+
.aboutPageAppBarTitle,
1723
// style: GoogleFonts.poppins(color: TaskWarriorColors.white),
1824
style: TextStyle(
1925
fontFamily: FontFamily.poppins,

lib/app/modules/about/views/about_page_body.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,26 @@ import 'package:flutter_svg/flutter_svg.dart';
33

44
import 'package:get/get.dart';
55
import 'package:package_info_plus/package_info_plus.dart';
6+
import 'package:taskwarrior/app/modules/about/controllers/about_controller.dart';
67
import 'package:taskwarrior/app/utils/gen/assets.gen.dart';
78
import 'package:taskwarrior/app/utils/gen/fonts.gen.dart';
9+
import 'package:taskwarrior/app/utils/language/sentence_manager.dart';
810
import 'package:url_launcher/url_launcher.dart';
911

1012
import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart';
1113
import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart';
1214
import 'package:taskwarrior/app/utils/theme/app_settings.dart';
1315

1416
class AboutPageBody extends StatelessWidget {
15-
const AboutPageBody({super.key});
17+
final AboutController aboutController;
18+
const AboutPageBody({required this.aboutController, super.key});
1619

1720
@override
1821
Widget build(BuildContext context) {
1922
String introduction =
20-
"This project aims to build an app for Taskwarrior. It is your task management app across all platforms. It helps you manage your tasks and filter them as per your needs.";
23+
SentenceManager(currentLanguage: aboutController.selectedLanguage.value)
24+
.sentences
25+
.aboutPageProjectDescription;
2126

2227
return Padding(
2328
padding: EdgeInsets.only(
@@ -247,7 +252,10 @@ class AboutPageBody extends StatelessWidget {
247252
height: Get.height * 0.04,
248253
),
249254
Text(
250-
"Eager to enhance this project? Visit our GitHub repository.",
255+
SentenceManager(
256+
currentLanguage: aboutController.selectedLanguage.value)
257+
.sentences
258+
.aboutPageGitHubLink,
251259
textAlign: TextAlign.center,
252260
style: TextStyle(
253261
fontFamily: FontFamily.poppins,

lib/app/modules/about/views/about_view.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ class AboutView extends GetView<AboutController> {
1414
@override
1515
Widget build(BuildContext context) {
1616
return Scaffold(
17-
appBar: const AboutPageAppBar(),
17+
appBar: AboutPageAppBar(aboutController: controller,),
1818
backgroundColor: AppSettings.isDarkMode
1919
? TaskWarriorColors.kprimaryBackgroundColor
2020
: TaskWarriorColors.white,
21-
body: const AboutPageBody(),
21+
body: AboutPageBody(
22+
aboutController: controller,
23+
),
2224
);
2325
}
2426
}

lib/app/modules/home/views/add_task_bottom_sheet.dart

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import 'package:taskwarrior/app/modules/home/controllers/home_controller.dart';
1111
import 'package:taskwarrior/app/modules/home/controllers/widget.controller.dart';
1212
import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart';
1313
import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart';
14+
import 'package:taskwarrior/app/utils/language/sentence_manager.dart';
1415
import 'package:taskwarrior/app/utils/taskfunctions/taskparser.dart';
1516
import 'package:taskwarrior/app/utils/theme/app_settings.dart';
1617

@@ -36,7 +37,10 @@ class AddTaskBottomSheet extends StatelessWidget {
3637
: TaskWarriorColors.kLightDialogBackGroundColor,
3738
title: Center(
3839
child: Text(
39-
'Add Task',
40+
SentenceManager(
41+
currentLanguage: homeController.selectedLanguage.value)
42+
.sentences
43+
.addTaskTitle,
4044
style: TextStyle(
4145
color: AppSettings.isDarkMode
4246
? TaskWarriorColors.white
@@ -94,7 +98,11 @@ class AddTaskBottomSheet extends StatelessWidget {
9498
: TaskWarriorColors.black,
9599
),
96100
decoration: InputDecoration(
97-
hintText: 'Add tags',
101+
hintText: SentenceManager(
102+
currentLanguage:
103+
homeController.selectedLanguage.value)
104+
.sentences
105+
.addTaskAddTags,
98106
hintStyle: TextStyle(
99107
color: AppSettings.isDarkMode
100108
? TaskWarriorColors.white
@@ -106,12 +114,11 @@ class AddTaskBottomSheet extends StatelessWidget {
106114
},
107115
),
108116
),
109-
// Replace ElevatedButton with IconButton
110117
IconButton(
111118
onPressed: () {
112119
addTag(homeController.tagcontroller.text.trim());
113120
},
114-
icon: const Icon(Icons.add), // Plus icon
121+
icon: const Icon(Icons.add),
115122
),
116123
],
117124
),
@@ -139,22 +146,31 @@ class AddTaskBottomSheet extends StatelessWidget {
139146
: TaskWarriorColors.black,
140147
),
141148
decoration: InputDecoration(
142-
hintText: 'Enter Task',
149+
hintText: SentenceManager(
150+
currentLanguage: homeController.selectedLanguage.value)
151+
.sentences
152+
.addTaskEnterTask,
143153
hintStyle: TextStyle(
144154
color: AppSettings.isDarkMode
145155
? TaskWarriorColors.white
146156
: TaskWarriorColors.black,
147157
),
148158
),
149159
validator: (name) => name != null && name.isEmpty
150-
? 'You cannot leave this field empty!'
160+
? SentenceManager(
161+
currentLanguage: homeController.selectedLanguage.value)
162+
.sentences
163+
.addTaskFieldCannotBeEmpty
151164
: null,
152165
);
153166

154167
Widget buildDueDate(BuildContext context) => Row(
155168
children: [
156169
Text(
157-
"Due : ",
170+
SentenceManager(
171+
currentLanguage: homeController.selectedLanguage.value)
172+
.sentences
173+
.addTaskDue,
158174
style: GoogleFonts.poppins(
159175
color: AppSettings.isDarkMode
160176
? TaskWarriorColors.white
@@ -178,7 +194,11 @@ class AddTaskBottomSheet extends StatelessWidget {
178194
controller:
179195
TextEditingController(text: homeController.dueString.value),
180196
decoration: InputDecoration(
181-
hintText: 'Select due date',
197+
hintText: SentenceManager(
198+
currentLanguage:
199+
homeController.selectedLanguage.value)
200+
.sentences
201+
.addTaskTitle,
182202
hintStyle: homeController.inThePast.value
183203
? TextStyle(color: TaskWarriorColors.red)
184204
: TextStyle(
@@ -291,7 +311,11 @@ class AddTaskBottomSheet extends StatelessWidget {
291311

292312
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
293313
content: Text(
294-
"The selected time is in the past.",
314+
SentenceManager(
315+
currentLanguage:
316+
homeController.selectedLanguage.value)
317+
.sentences
318+
.addTaskTimeInPast,
295319
style: TextStyle(
296320
color: AppSettings.isDarkMode
297321
? TaskWarriorColors.kprimaryTextColor
@@ -324,7 +348,10 @@ class AddTaskBottomSheet extends StatelessWidget {
324348
crossAxisAlignment: CrossAxisAlignment.center,
325349
children: [
326350
Text(
327-
'Priority : ',
351+
"${SentenceManager(
352+
currentLanguage: homeController.selectedLanguage.value)
353+
.sentences
354+
.addTaskPriority} :",
328355
style: GoogleFonts.poppins(
329356
fontWeight: TaskWarriorFonts.bold,
330357
color: AppSettings.isDarkMode
@@ -372,7 +399,10 @@ class AddTaskBottomSheet extends StatelessWidget {
372399
BuildContext context, HomeController homeController) =>
373400
TextButton(
374401
child: Text(
375-
'Cancel',
402+
SentenceManager(
403+
currentLanguage: homeController.selectedLanguage.value)
404+
.sentences
405+
.addTaskCancel,
376406
style: TextStyle(
377407
color: AppSettings.isDarkMode
378408
? TaskWarriorColors.white
@@ -393,7 +423,10 @@ class AddTaskBottomSheet extends StatelessWidget {
393423
Widget buildAddButton(BuildContext context) {
394424
return TextButton(
395425
child: Text(
396-
"Add",
426+
SentenceManager(
427+
currentLanguage: homeController.selectedLanguage.value)
428+
.sentences
429+
.addTaskAdd,
397430
style: TextStyle(
398431
color: AppSettings.isDarkMode
399432
? TaskWarriorColors.white
@@ -437,7 +470,10 @@ class AddTaskBottomSheet extends StatelessWidget {
437470

438471
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
439472
content: Text(
440-
'Task Added Successfully. Tap to Edit',
473+
SentenceManager(
474+
currentLanguage: homeController.selectedLanguage.value)
475+
.sentences
476+
.addTaskTaskAddedSuccessfully,
441477
style: TextStyle(
442478
color: AppSettings.isDarkMode
443479
? TaskWarriorColors.kprimaryTextColor

lib/app/modules/settings/views/settings_page_select_the_language_trailing.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class SettingsPageSelectTheLanguageTrailing extends StatelessWidget {
3636
}).toList(),
3737
dropdownColor: AppSettings.isDarkMode
3838
? TaskWarriorColors.kprimaryBackgroundColor
39-
: TaskWarriorColors.kLightPrimaryBackgroundColor
39+
: TaskWarriorColors.kLightPrimaryBackgroundColor,
4040
),
4141
);
4242
}
@@ -49,6 +49,12 @@ class SettingsPageSelectTheLanguageTrailing extends StatelessWidget {
4949
return 'Hindi';
5050
case SupportedLanguage.marathi:
5151
return 'Marathi';
52+
case SupportedLanguage.french:
53+
return 'Français';
54+
case SupportedLanguage.spanish:
55+
return 'Español';
56+
case SupportedLanguage.bengali:
57+
return 'বাংলা';
5258
default:
5359
return '';
5460
}

lib/app/modules/splash/controllers/splash_controller.dart

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
// ignore_for_file: depend_on_referenced_packages
1+
// ignore_for_file: body_might_complete_normally_catch_error, depend_on_referenced_packages
22

33
import 'dart:io';
44

5+
import 'package:flutter/foundation.dart';
56
import 'package:get/get.dart';
7+
import 'package:in_app_update/in_app_update.dart';
68
import 'package:path_provider/path_provider.dart';
79
import 'package:shared_preferences/shared_preferences.dart';
810
import 'package:taskwarrior/app/models/storage.dart';
@@ -19,6 +21,7 @@ class SplashController extends GetxController {
1921
@override
2022
void onInit() async {
2123
super.onInit();
24+
await checkForUpdate();
2225
initBaseDir().then((_) {
2326
_checkProfiles();
2427
profilesMap.value = _profiles.profilesMap();
@@ -102,4 +105,27 @@ class SplashController extends GetxController {
102105
Get.offNamed(Routes.ONBOARDING);
103106
}
104107
}
108+
109+
Future<void> checkForUpdate() async {
110+
try {
111+
AppUpdateInfo updateInfo = await InAppUpdate.checkForUpdate();
112+
if (updateInfo.updateAvailability == UpdateAvailability.updateAvailable) {
113+
if (updateInfo.immediateUpdateAllowed) {
114+
InAppUpdate.performImmediateUpdate().catchError((e) {
115+
debugPrint(e.toString());
116+
});
117+
} else if (updateInfo.flexibleUpdateAllowed) {
118+
InAppUpdate.startFlexibleUpdate().then((_) {
119+
InAppUpdate.completeFlexibleUpdate().catchError((e) {
120+
debugPrint(e.toString());
121+
});
122+
}).catchError((e) {
123+
debugPrint(e.toString());
124+
});
125+
}
126+
}
127+
} catch (e) {
128+
debugPrint(e.toString());
129+
}
130+
}
105131
}

0 commit comments

Comments
 (0)