diff --git a/android/app/build.gradle b/android/app/build.gradle index e727b0af..e43416b0 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -60,7 +60,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 30 + compileSdkVersion 31 sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -70,7 +70,7 @@ android { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.hellohasan.flutter_getx_template" minSdkVersion 19 - targetSdkVersion 30 + targetSdkVersion 31 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 49559808..ec5c4258 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -8,6 +8,7 @@ android:icon="@mipmap/ic_launcher"> InkWell( + child: controller.selectedLangCode.contains('en') + ? const Icon(Icons.radio_button_checked) + : const Icon(Icons.radio_button_off), + onTap: () { + controller.updateLanguage('en'); + }, + )), + const SizedBox( + width: 8.0, + ), + InkWell( + onTap: () { + controller.updateLanguage('en'); + }, + child: const Text( + 'English', + style: settingsItemStyle, + ), + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.only(left: 18.0, bottom: 0.0), + child: Row(children: [ + Obx( + () => InkWell( + child: controller.selectedLangCode.contains('bn') + ? const Icon(Icons.radio_button_checked) + : const Icon(Icons.radio_button_off), + onTap: () { + controller.updateLanguage('bn'); + }, + ), + ), + const SizedBox( + width: 8.0, + ), + InkWell( + onTap: () { + controller.updateLanguage('bn'); + }, + child: const Text('বাংলা', style: settingsItemStyle)), + ]), + ), + ], + ); + } +} diff --git a/lib/app/modules/favorite/views/favorite_view.dart b/lib/app/modules/favorite/views/favorite_view.dart index f298235b..68000b55 100644 --- a/lib/app/modules/favorite/views/favorite_view.dart +++ b/lib/app/modules/favorite/views/favorite_view.dart @@ -9,15 +9,15 @@ class FavoriteView extends BaseView { @override PreferredSizeWidget? appBar(BuildContext context) { return CustomAppBar( - appBarTitleText: 'Favorite', + appBarTitleText: appLocalization.bottomNavFavorite, ); } @override Widget body(BuildContext context) { - return const Center( + return Center( child: Text( - 'FavoriteView is working', + appLocalization.favoriteViewMessage, style: titleStyle, ), ); diff --git a/lib/app/modules/home/views/home_view.dart b/lib/app/modules/home/views/home_view.dart index 04e01166..857e6c2b 100644 --- a/lib/app/modules/home/views/home_view.dart +++ b/lib/app/modules/home/views/home_view.dart @@ -16,7 +16,7 @@ class HomeView extends BaseView { @override PreferredSizeWidget? appBar(BuildContext context) { return CustomAppBar( - appBarTitleText: 'GetX Templates on GitHub', + appBarTitleText: appLocalization.homeViewAppBarTitle, ); } diff --git a/lib/app/modules/main/views/bottom_nav_bar.dart b/lib/app/modules/main/views/bottom_nav_bar.dart index 611e464a..cae5c2cc 100644 --- a/lib/app/modules/main/views/bottom_nav_bar.dart +++ b/lib/app/modules/main/views/bottom_nav_bar.dart @@ -16,7 +16,7 @@ class BottomNavBar extends StatelessWidget { BottomNavBar({Key? key, required this.onNewMenuSelected}) : super(key: key); late AppLocalizations appLocalization; - final navController = BottomNavController(); + final navController = Get.put(BottomNavController()); final Key bottomNavKey = GlobalKey(); diff --git a/lib/app/modules/settings/controllers/settings_controller.dart b/lib/app/modules/settings/controllers/settings_controller.dart index 8b7201b9..74409126 100644 --- a/lib/app/modules/settings/controllers/settings_controller.dart +++ b/lib/app/modules/settings/controllers/settings_controller.dart @@ -1,9 +1,18 @@ +import 'package:flutter/cupertino.dart'; import 'package:get/get.dart'; import '/app/core/base/base_controller.dart'; class SettingsController extends BaseController { - final count = 0.obs; + var selectedLangCode = "en".obs; - void increment() => count.value++; + updateLanguage(var langCode){ + print("Tapped: $langCode"); + selectedLangCode.value = langCode; + } + + void changeLanguage() { + var locale = selectedLangCode.value == 'en' ? Locale('en', 'US') : Locale('bn', 'BD'); + Get.updateLocale(locale); + } } diff --git a/lib/app/modules/settings/views/settings_view.dart b/lib/app/modules/settings/views/settings_view.dart index 734131cd..1cc780af 100644 --- a/lib/app/modules/settings/views/settings_view.dart +++ b/lib/app/modules/settings/views/settings_view.dart @@ -1,10 +1,17 @@ import 'package:flutter/material.dart'; +import 'package:flutter_getx_template/app/core/values/app_colors.dart'; +import 'package:flutter_getx_template/app/core/values/text_styles.dart'; +import 'package:flutter_getx_template/app/core/widget/alert_widget.dart'; +import 'package:get/get.dart'; +import '../../main/controllers/bottom_nav_controller.dart'; import '/app/modules/settings/widgets/item_settings_widgets.dart'; import '/app/core/base/base_view.dart'; import '/app/core/widget/custom_app_bar.dart'; import '/app/modules/settings/controllers/settings_controller.dart'; class SettingsView extends BaseView { + BottomNavController bottomNavController = Get.find(); + @override PreferredSizeWidget? appBar(BuildContext context) { return CustomAppBar( @@ -47,15 +54,59 @@ class SettingsView extends BaseView { } void _onThemeItemClicked() { - showToast('Theme: Development in progress'); + showToast(appLocalization.themeToast); } void _onLanguageItemClicked() { - showToast('Language: Development in progress'); + Get.defaultDialog( + title: appLocalization.languageSelectorTitle, + titleStyle: titleStyle, + middleText: '', + content: AlertWidget(), + actions: [ + Padding( + padding: const EdgeInsets.only(right: 8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + ElevatedButton( + child: Text( + appLocalization.cancelText, + style: buttonTextStyle, + ), + style: ElevatedButton.styleFrom( + primary: AppColors.appBarColor, + ), + onPressed: () { + Get.back(); + }, + ), + const SizedBox( + width: 4.0, + ), + ElevatedButton( + onPressed: () { + Get.back(); + controller.changeLanguage(); + bottomNavController.updateSelectedIndex(2); + showToast(appLocalization.languageToast); + }, + child: Text( + appLocalization.confirmText, + style: buttonTextStyle, + ), + style: ElevatedButton.styleFrom( + primary: AppColors.appBarColor, + ), + ), + ], + ), + ) + ], + ); } void _onFontSizeItemClicked() { - showToast('Font Size: Development in progress'); + showToast(appLocalization.fontSizeToast); } - } diff --git a/lib/l10n/app_bn.arb b/lib/l10n/app_bn.arb index 32c6cfb5..0c3c1bab 100644 --- a/lib/l10n/app_bn.arb +++ b/lib/l10n/app_bn.arb @@ -5,5 +5,13 @@ "titleOtherView": "অন্যান্য", "settingsTheme": "থিম", "settingsLanguage": "ভাষা", - "settingsFontSize": "অক্ষরের আকার" + "settingsFontSize": "অক্ষরের আকার", + "languageToast": "ভাষা: ভাষা পরিবর্তন হয়েছে", + "fontSizeToast": "অক্ষরের আকার: অক্ষরের আকার পরিবর্তনের কাজ চলছে", + "themeToast": "থিম: থিম পরিবর্তনের কাজ চলছে", + "favoriteViewMessage": "ফেভারিট স্ক্রিন এর কাজ চলছে", + "homeViewAppBarTitle": "GitHub এর GetX টেমপ্লেটসমূহ", + "languageSelectorTitle": "ভাষা নির্বাচন", + "cancelText": "বাতিল করুন", + "confirmText": "নিশ্চিত করুন" } \ No newline at end of file diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 0971dfe8..a4228300 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -5,5 +5,13 @@ "titleOtherView": "OtherView", "settingsTheme": "Theme", "settingsLanguage": "Language", - "settingsFontSize": "Font Size" + "settingsFontSize": "Font Size", + "languageToast": "Language: Language Changed", + "fontSizeToast": "Font Size: Development in progress", + "themeToast": "Theme: Development in progress", + "favoriteViewMessage": "FavoriteView is working", + "homeViewAppBarTitle": "GetX Templates on GitHub", + "languageSelectorTitle": "Select Language", + "cancelText": "Cancel", + "confirmText": "Confirm" } \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 7d91dc6d..03733025 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -343,6 +343,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3" meta: dependency: transitive description: @@ -613,7 +620,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.3" + version: "0.4.8" typed_data: dependency: transitive description: