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

Multi language support implemented, alert dialogue implemented #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
hasancse91 marked this conversation as resolved.
Show resolved Hide resolved
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
Expand Down
6 changes: 6 additions & 0 deletions lib/app/core/values/text_styles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ const settingsItemStyle = TextStyle(
fontWeight: FontWeight.w400,
);

const buttonTextStyle = TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
color: Colors.white
);

final cardTagStyle = titleStyle.copyWith(color: AppColors.textColorGreyDark);

const titleStyleWhite = TextStyle(
Expand Down
70 changes: 70 additions & 0 deletions lib/app/core/widget/alert_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_getx_template/app/modules/settings/controllers/settings_controller.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart';

import '../values/text_styles.dart';

class AlertWidget extends StatelessWidget {
SettingsController controller = Get.find();

@override
Widget build(BuildContext context) {
return Column(
children: [
Padding(
padding: const EdgeInsets.only(left: 18.0, bottom: 4.0),
child: Row(
children: [
Obx(() => 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)),
]),
),
],
);
}
}
6 changes: 3 additions & 3 deletions lib/app/modules/favorite/views/favorite_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ class FavoriteView extends BaseView<FavoriteController> {
@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,
),
);
Expand Down
2 changes: 1 addition & 1 deletion lib/app/modules/home/views/home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class HomeView extends BaseView<HomeController> {
@override
PreferredSizeWidget? appBar(BuildContext context) {
return CustomAppBar(
appBarTitleText: 'GetX Templates on GitHub',
appBarTitleText: appLocalization.homeViewAppBarTitle,
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/app/modules/main/views/bottom_nav_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
13 changes: 11 additions & 2 deletions lib/app/modules/settings/controllers/settings_controller.dart
Original file line number Diff line number Diff line change
@@ -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);
}
}
59 changes: 55 additions & 4 deletions lib/app/modules/settings/views/settings_view.dart
Original file line number Diff line number Diff line change
@@ -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<SettingsController> {
BottomNavController bottomNavController = Get.find();

@override
PreferredSizeWidget? appBar(BuildContext context) {
return CustomAppBar(
Expand Down Expand Up @@ -47,15 +54,59 @@ class SettingsView extends BaseView<SettingsController> {
}

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);
}

}
10 changes: 9 additions & 1 deletion lib/l10n/app_bn.arb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,13 @@
"titleOtherView": "অন্যান্য",
"settingsTheme": "থিম",
"settingsLanguage": "ভাষা",
"settingsFontSize": "অক্ষরের আকার"
"settingsFontSize": "অক্ষরের আকার",
"languageToast": "ভাষা: ভাষা পরিবর্তন হয়েছে",
"fontSizeToast": "অক্ষরের আকার: অক্ষরের আকার পরিবর্তনের কাজ চলছে",
"themeToast": "থিম: থিম পরিবর্তনের কাজ চলছে",
"favoriteViewMessage": "ফেভারিট স্ক্রিন এর কাজ চলছে",
"homeViewAppBarTitle": "GitHub এর GetX টেমপ্লেটসমূহ",
"languageSelectorTitle": "ভাষা নির্বাচন",
"cancelText": "বাতিল করুন",
"confirmText": "নিশ্চিত করুন"
}
10 changes: 9 additions & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
9 changes: 8 additions & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down