Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for more languages #367

Merged
merged 6 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions lib/app/modules/about/controllers/about_controller.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import 'package:get/get.dart';
import 'package:taskwarrior/app/utils/language/supported_language.dart';
import 'package:taskwarrior/app/utils/theme/app_settings.dart';

class AboutController extends GetxController {
//TODO: Implement AboutController
final Rx<SupportedLanguage> selectedLanguage = SupportedLanguage.english.obs;

final count = 0.obs;
@override
void onInit() {
super.onInit();
initLanguage();
}



void increment() => count.value++;
void initLanguage() {
selectedLanguage.value = AppSettings.selectedLanguage;
}
}
10 changes: 8 additions & 2 deletions lib/app/modules/about/views/about_page_app_bar.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
import 'package:flutter/material.dart';
import 'package:taskwarrior/app/modules/about/controllers/about_controller.dart';


import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart';
import 'package:taskwarrior/app/utils/gen/fonts.gen.dart';
import 'package:taskwarrior/app/utils/language/sentence_manager.dart';

class AboutPageAppBar extends StatelessWidget implements PreferredSizeWidget {
const AboutPageAppBar({super.key});
final AboutController aboutController;
const AboutPageAppBar({required this.aboutController,super.key});

@override
Widget build(BuildContext context) {
return AppBar(
centerTitle: true,
backgroundColor: TaskWarriorColors.kprimaryBackgroundColor,
title: Text(
'About',
SentenceManager(
currentLanguage: aboutController.selectedLanguage.value)
.sentences
.aboutPageAppBarTitle,
// style: GoogleFonts.poppins(color: TaskWarriorColors.white),
style: TextStyle(
fontFamily: FontFamily.poppins,
Expand Down
14 changes: 11 additions & 3 deletions lib/app/modules/about/views/about_page_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,26 @@ import 'package:flutter_svg/flutter_svg.dart';

import 'package:get/get.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:taskwarrior/app/modules/about/controllers/about_controller.dart';
import 'package:taskwarrior/app/utils/gen/assets.gen.dart';
import 'package:taskwarrior/app/utils/gen/fonts.gen.dart';
import 'package:taskwarrior/app/utils/language/sentence_manager.dart';
import 'package:url_launcher/url_launcher.dart';

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

class AboutPageBody extends StatelessWidget {
const AboutPageBody({super.key});
final AboutController aboutController;
const AboutPageBody({required this.aboutController, super.key});

@override
Widget build(BuildContext context) {
String introduction =
"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.";
SentenceManager(currentLanguage: aboutController.selectedLanguage.value)
.sentences
.aboutPageProjectDescription;

return Padding(
padding: EdgeInsets.only(
Expand Down Expand Up @@ -247,7 +252,10 @@ class AboutPageBody extends StatelessWidget {
height: Get.height * 0.04,
),
Text(
"Eager to enhance this project? Visit our GitHub repository.",
SentenceManager(
currentLanguage: aboutController.selectedLanguage.value)
.sentences
.aboutPageGitHubLink,
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: FontFamily.poppins,
Expand Down
6 changes: 4 additions & 2 deletions lib/app/modules/about/views/about_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ class AboutView extends GetView<AboutController> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: const AboutPageAppBar(),
appBar: AboutPageAppBar(aboutController: controller,),
backgroundColor: AppSettings.isDarkMode
? TaskWarriorColors.kprimaryBackgroundColor
: TaskWarriorColors.white,
body: const AboutPageBody(),
body: AboutPageBody(
aboutController: controller,
),
);
}
}
62 changes: 49 additions & 13 deletions lib/app/modules/home/views/add_task_bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:taskwarrior/app/modules/home/controllers/home_controller.dart';
import 'package:taskwarrior/app/modules/home/controllers/widget.controller.dart';
import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart';
import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart';
import 'package:taskwarrior/app/utils/language/sentence_manager.dart';
import 'package:taskwarrior/app/utils/taskfunctions/taskparser.dart';
import 'package:taskwarrior/app/utils/theme/app_settings.dart';

Expand All @@ -36,7 +37,10 @@ class AddTaskBottomSheet extends StatelessWidget {
: TaskWarriorColors.kLightDialogBackGroundColor,
title: Center(
child: Text(
'Add Task',
SentenceManager(
currentLanguage: homeController.selectedLanguage.value)
.sentences
.addTaskTitle,
style: TextStyle(
color: AppSettings.isDarkMode
? TaskWarriorColors.white
Expand Down Expand Up @@ -94,7 +98,11 @@ class AddTaskBottomSheet extends StatelessWidget {
: TaskWarriorColors.black,
),
decoration: InputDecoration(
hintText: 'Add tags',
hintText: SentenceManager(
currentLanguage:
homeController.selectedLanguage.value)
.sentences
.addTaskAddTags,
hintStyle: TextStyle(
color: AppSettings.isDarkMode
? TaskWarriorColors.white
Expand All @@ -106,12 +114,11 @@ class AddTaskBottomSheet extends StatelessWidget {
},
),
),
// Replace ElevatedButton with IconButton
IconButton(
onPressed: () {
addTag(homeController.tagcontroller.text.trim());
},
icon: const Icon(Icons.add), // Plus icon
icon: const Icon(Icons.add),
),
],
),
Expand Down Expand Up @@ -139,22 +146,31 @@ class AddTaskBottomSheet extends StatelessWidget {
: TaskWarriorColors.black,
),
decoration: InputDecoration(
hintText: 'Enter Task',
hintText: SentenceManager(
currentLanguage: homeController.selectedLanguage.value)
.sentences
.addTaskEnterTask,
hintStyle: TextStyle(
color: AppSettings.isDarkMode
? TaskWarriorColors.white
: TaskWarriorColors.black,
),
),
validator: (name) => name != null && name.isEmpty
? 'You cannot leave this field empty!'
? SentenceManager(
currentLanguage: homeController.selectedLanguage.value)
.sentences
.addTaskFieldCannotBeEmpty
: null,
);

Widget buildDueDate(BuildContext context) => Row(
children: [
Text(
"Due : ",
SentenceManager(
currentLanguage: homeController.selectedLanguage.value)
.sentences
.addTaskDue,
style: GoogleFonts.poppins(
color: AppSettings.isDarkMode
? TaskWarriorColors.white
Expand All @@ -178,7 +194,11 @@ class AddTaskBottomSheet extends StatelessWidget {
controller:
TextEditingController(text: homeController.dueString.value),
decoration: InputDecoration(
hintText: 'Select due date',
hintText: SentenceManager(
currentLanguage:
homeController.selectedLanguage.value)
.sentences
.addTaskTitle,
hintStyle: homeController.inThePast.value
? TextStyle(color: TaskWarriorColors.red)
: TextStyle(
Expand Down Expand Up @@ -291,7 +311,11 @@ class AddTaskBottomSheet extends StatelessWidget {

ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(
"The selected time is in the past.",
SentenceManager(
currentLanguage:
homeController.selectedLanguage.value)
.sentences
.addTaskTimeInPast,
style: TextStyle(
color: AppSettings.isDarkMode
? TaskWarriorColors.kprimaryTextColor
Expand Down Expand Up @@ -324,7 +348,10 @@ class AddTaskBottomSheet extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'Priority : ',
"${SentenceManager(
currentLanguage: homeController.selectedLanguage.value)
.sentences
.addTaskPriority} :",
style: GoogleFonts.poppins(
fontWeight: TaskWarriorFonts.bold,
color: AppSettings.isDarkMode
Expand Down Expand Up @@ -372,7 +399,10 @@ class AddTaskBottomSheet extends StatelessWidget {
BuildContext context, HomeController homeController) =>
TextButton(
child: Text(
'Cancel',
SentenceManager(
currentLanguage: homeController.selectedLanguage.value)
.sentences
.addTaskCancel,
style: TextStyle(
color: AppSettings.isDarkMode
? TaskWarriorColors.white
Expand All @@ -393,7 +423,10 @@ class AddTaskBottomSheet extends StatelessWidget {
Widget buildAddButton(BuildContext context) {
return TextButton(
child: Text(
"Add",
SentenceManager(
currentLanguage: homeController.selectedLanguage.value)
.sentences
.addTaskAdd,
style: TextStyle(
color: AppSettings.isDarkMode
? TaskWarriorColors.white
Expand Down Expand Up @@ -437,7 +470,10 @@ class AddTaskBottomSheet extends StatelessWidget {

ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(
'Task Added Successfully. Tap to Edit',
SentenceManager(
currentLanguage: homeController.selectedLanguage.value)
.sentences
.addTaskTaskAddedSuccessfully,
style: TextStyle(
color: AppSettings.isDarkMode
? TaskWarriorColors.kprimaryTextColor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SettingsPageSelectTheLanguageTrailing extends StatelessWidget {
}).toList(),
dropdownColor: AppSettings.isDarkMode
? TaskWarriorColors.kprimaryBackgroundColor
: TaskWarriorColors.kLightPrimaryBackgroundColor
: TaskWarriorColors.kLightPrimaryBackgroundColor,
),
);
}
Expand All @@ -49,6 +49,12 @@ class SettingsPageSelectTheLanguageTrailing extends StatelessWidget {
return 'Hindi';
case SupportedLanguage.marathi:
return 'Marathi';
case SupportedLanguage.french:
return 'Français';
case SupportedLanguage.spanish:
return 'Español';
case SupportedLanguage.bengali:
return 'বাংলা';
default:
return '';
}
Expand Down
28 changes: 27 additions & 1 deletion lib/app/modules/splash/controllers/splash_controller.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// ignore_for_file: depend_on_referenced_packages
// ignore_for_file: body_might_complete_normally_catch_error, depend_on_referenced_packages

import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:get/get.dart';
import 'package:in_app_update/in_app_update.dart';
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:taskwarrior/app/models/storage.dart';
Expand All @@ -19,6 +21,7 @@ class SplashController extends GetxController {
@override
void onInit() async {
super.onInit();
await checkForUpdate();
initBaseDir().then((_) {
_checkProfiles();
profilesMap.value = _profiles.profilesMap();
Expand Down Expand Up @@ -102,4 +105,27 @@ class SplashController extends GetxController {
Get.offNamed(Routes.ONBOARDING);
}
}

Future<void> checkForUpdate() async {
try {
AppUpdateInfo updateInfo = await InAppUpdate.checkForUpdate();
if (updateInfo.updateAvailability == UpdateAvailability.updateAvailable) {
if (updateInfo.immediateUpdateAllowed) {
InAppUpdate.performImmediateUpdate().catchError((e) {
debugPrint(e.toString());
});
} else if (updateInfo.flexibleUpdateAllowed) {
InAppUpdate.startFlexibleUpdate().then((_) {
InAppUpdate.completeFlexibleUpdate().catchError((e) {
debugPrint(e.toString());
});
}).catchError((e) {
debugPrint(e.toString());
});
}
}
} catch (e) {
debugPrint(e.toString());
}
}
}
Loading
Loading