Compare commits

..

2 Commits

Author SHA1 Message Date
JingChiang
57968f7935 feat: add App title and welcome message in personal info page english translate 2024-11-30 13:45:18 +08:00
JingChiang
00ff77a49a refactor: remove unnecessary code 2024-11-30 13:43:45 +08:00
10 changed files with 40 additions and 14 deletions

View File

@ -20,13 +20,6 @@ class _HomePageState extends State<HomePage> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
// _setLanguage();
}
void _setLanguage() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
String preLanguage = prefs.getString("language") ?? "";
Locale locale = preLanguage == "" ? Locale(preLanguage) : Localizations.localeOf(context);
S.load(locale);
} }
@override @override
@ -52,7 +45,7 @@ class _HomePageState extends State<HomePage> {
), ),
Center( Center(
child: Text( child: Text(
'全方位照護守護者', S.of(context).app_name,
style: TextStyle(fontSize: 24, height: 5), style: TextStyle(fontSize: 24, height: 5),
), ),
), ),

View File

@ -47,7 +47,7 @@ class _MessagePageState extends State<MessagePage> {
), ),
Center( Center(
child: Text( child: Text(
'全方位照護守護者', S.of(context).app_name,
style: TextStyle(fontSize: 24, height: 5), style: TextStyle(fontSize: 24, height: 5),
), ),
), ),

View File

@ -160,7 +160,7 @@ class _PersonalInfoState extends State<PersonalInfo> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Text(
_username + ' 您好', S.of(context).welcome_message(_username),
style: TextStyle(fontSize: 28, color: Colors.black), style: TextStyle(fontSize: 28, color: Colors.black),
), ),
], ],

View File

@ -255,7 +255,7 @@ class _RegisterPageState extends State<RegisterPage> {
), ),
), ),
Text( Text(
'全方位照護守護者', S.of(context).app_name,
style: TextStyle( style: TextStyle(
fontSize: 32, fontSize: 32,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,

View File

@ -31,12 +31,16 @@ class MessageLookup extends MessageLookupByLibrary {
static String m4(displayIndex) => "ID: ${displayIndex}"; static String m4(displayIndex) => "ID: ${displayIndex}";
static String m5(username) => "Welcome, ${username}!";
final messages = _notInlinedMessages(_notInlinedMessages); final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{ static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"account_setting": MessageLookupByLibrary.simpleMessage("Account"), "account_setting": MessageLookupByLibrary.simpleMessage("Account"),
"additional_information": "additional_information":
MessageLookupByLibrary.simpleMessage("Knowledge"), MessageLookupByLibrary.simpleMessage("Knowledge"),
"address": MessageLookupByLibrary.simpleMessage("Address"), "address": MessageLookupByLibrary.simpleMessage("Address"),
"app_name":
MessageLookupByLibrary.simpleMessage("Comprehensive Care Guardian"),
"basic_information_setting": "basic_information_setting":
MessageLookupByLibrary.simpleMessage("Basic Information"), MessageLookupByLibrary.simpleMessage("Basic Information"),
"call_phone": "call_phone":
@ -99,6 +103,7 @@ class MessageLookup extends MessageLookupByLibrary {
"register_turn_back": "register_turn_back":
MessageLookupByLibrary.simpleMessage("Return to Login Page"), MessageLookupByLibrary.simpleMessage("Return to Login Page"),
"save": MessageLookupByLibrary.simpleMessage("Save"), "save": MessageLookupByLibrary.simpleMessage("Save"),
"switch_camera": MessageLookupByLibrary.simpleMessage("Switch View") "switch_camera": MessageLookupByLibrary.simpleMessage("Switch View"),
"welcome_message": m5
}; };
} }

View File

@ -31,11 +31,14 @@ class MessageLookup extends MessageLookupByLibrary {
static String m4(displayIndex) => "編號: ${displayIndex}"; static String m4(displayIndex) => "編號: ${displayIndex}";
static String m5(username) => "${username} 您好!";
final messages = _notInlinedMessages(_notInlinedMessages); final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{ static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"account_setting": MessageLookupByLibrary.simpleMessage("帳號設定"), "account_setting": MessageLookupByLibrary.simpleMessage("帳號設定"),
"additional_information": MessageLookupByLibrary.simpleMessage("知識補充"), "additional_information": MessageLookupByLibrary.simpleMessage("知識補充"),
"address": MessageLookupByLibrary.simpleMessage("地址"), "address": MessageLookupByLibrary.simpleMessage("地址"),
"app_name": MessageLookupByLibrary.simpleMessage("全方位照護守護者"),
"basic_information_setting": "basic_information_setting":
MessageLookupByLibrary.simpleMessage("基本資料"), MessageLookupByLibrary.simpleMessage("基本資料"),
"call_phone": MessageLookupByLibrary.simpleMessage("撥打電話"), "call_phone": MessageLookupByLibrary.simpleMessage("撥打電話"),
@ -89,6 +92,7 @@ class MessageLookup extends MessageLookupByLibrary {
"register_success": MessageLookupByLibrary.simpleMessage("註冊成功"), "register_success": MessageLookupByLibrary.simpleMessage("註冊成功"),
"register_turn_back": MessageLookupByLibrary.simpleMessage("返回登入頁面"), "register_turn_back": MessageLookupByLibrary.simpleMessage("返回登入頁面"),
"save": MessageLookupByLibrary.simpleMessage("儲存變更"), "save": MessageLookupByLibrary.simpleMessage("儲存變更"),
"switch_camera": MessageLookupByLibrary.simpleMessage("切換畫面") "switch_camera": MessageLookupByLibrary.simpleMessage("切換畫面"),
"welcome_message": m5
}; };
} }

View File

@ -50,6 +50,16 @@ class S {
return Localizations.of<S>(context, S); return Localizations.of<S>(context, S);
} }
/// `Comprehensive Care Guardian`
String get app_name {
return Intl.message(
'Comprehensive Care Guardian',
name: 'app_name',
desc: '',
args: [],
);
}
/// `Email/Username` /// `Email/Username`
String get email_label { String get email_label {
return Intl.message( return Intl.message(
@ -270,6 +280,16 @@ class S {
); );
} }
/// `Welcome, {username}!`
String welcome_message(Object username) {
return Intl.message(
'Welcome, $username!',
name: 'welcome_message',
desc: '',
args: [username],
);
}
/// `Basic Information` /// `Basic Information`
String get basic_information_setting { String get basic_information_setting {
return Intl.message( return Intl.message(

View File

@ -1,4 +1,5 @@
{ {
"app_name": "Comprehensive Care Guardian",
"email_label": "Email/Username", "email_label": "Email/Username",
"password_label": "Password", "password_label": "Password",
"login_button": "Login", "login_button": "Login",
@ -25,6 +26,7 @@
"home": "Home", "home": "Home",
"welcome_message": "Welcome, {username}!",
"basic_information_setting": "Basic Information", "basic_information_setting": "Basic Information",
"account_setting": "Account", "account_setting": "Account",
"language_setting": "Language", "language_setting": "Language",

View File

@ -1,4 +1,5 @@
{ {
"app_name": "全方位照護守護者",
"email_label": "電子信箱/帳號", "email_label": "電子信箱/帳號",
"password_label": "密碼", "password_label": "密碼",
"login_button": "登入", "login_button": "登入",
@ -25,6 +26,7 @@
"home": "首頁", "home": "首頁",
"welcome_message": "{username} 您好!",
"basic_information_setting": "基本資料", "basic_information_setting": "基本資料",
"account_setting": "帳號設定", "account_setting": "帳號設定",
"language_setting": "語言設定", "language_setting": "語言設定",

View File

@ -186,7 +186,7 @@ class _LoginPageState extends State<LoginPage> {
), ),
), ),
Text( Text(
'全方位照護守護者', S.of(context).app_name,
style: TextStyle( style: TextStyle(
fontSize: 32, fontSize: 32,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,