From 00ec7c553dc333c4bc9ff130d65838e46e6441f2 Mon Sep 17 00:00:00 2001 From: chenxi Date: Tue, 13 Jun 2023 10:41:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E7=BB=91=E5=AE=9A=E7=9A=84ap?= =?UTF-8?q?ple=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/game_setting/account_binding_ui.lua | 48 ++++++-- lua/app/ui/game_setting/game_setting_ui.lua | 108 +++++++++++++----- 2 files changed, 117 insertions(+), 39 deletions(-) diff --git a/lua/app/ui/game_setting/account_binding_ui.lua b/lua/app/ui/game_setting/account_binding_ui.lua index 50bbc158..e56a6c34 100644 --- a/lua/app/ui/game_setting/account_binding_ui.lua +++ b/lua/app/ui/game_setting/account_binding_ui.lua @@ -13,13 +13,7 @@ function AccountBindUI:onLoadRootComplete() self.uiMap["account_bind_ui.title_bg_img.title_text"]:setText(I18N:getGlobalText(I18N.GlobalConst.MESSAGE_BOX_TITLE)) self.uiMap["account_bind_ui.title_bg_img.bg.content_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.BIND_TIPS_DESC)) - self.uiMap["account_bind_ui.title_bg_img.google_sign_btn"]:addClickListener(function() - if ModuleManager.AccountManager:getIsBinded() then - GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.ACCOUNT_ALREADY_BINDED_DESC)) - return - end - ModuleManager.AccountManager:bindAccount() - end) + self:initBindBtn() self.uiMap["account_bind_ui.close_btn"]:addClickListener(function() self:closeUI() end) @@ -30,11 +24,43 @@ function AccountBindUI:onLoadRootComplete() self:refreshAccountInfo() end -function AccountBindUI:refreshAccountInfo() - if ModuleManager.AccountManager:getIsBinded() then - self.uiMap["account_bind_ui.title_bg_img.google_sign_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACCOUNT_ALREADY_BINDED_DESC)) +function AccountBindUI:initBindBtn() + if Platform:isIosPlatform() then + self.uiMap["account_bind_ui.title_bg_img.apple_sign_btn"]:setVisible(true) + self.uiMap["account_bind_ui.title_bg_img.google_sign_btn"]:setVisible(false) + self.uiMap["account_bind_ui.title_bg_img.apple_sign_btn"]:addClickListener(function() + if ModuleManager.AccountManager:getIsBinded() then + GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.ACCOUNT_ALREADY_BINDED_DESC)) + return + end + ModuleManager.AccountManager:bindAccount() + end) else - self.uiMap["account_bind_ui.title_bg_img.google_sign_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.BIND_ACCOUNT_DESC)) + self.uiMap["account_bind_ui.title_bg_img.apple_sign_btn"]:setVisible(false) + self.uiMap["account_bind_ui.title_bg_img.google_sign_btn"]:setVisible(true) + self.uiMap["account_bind_ui.title_bg_img.google_sign_btn"]:addClickListener(function() + if ModuleManager.AccountManager:getIsBinded() then + GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.ACCOUNT_ALREADY_BINDED_DESC)) + return + end + ModuleManager.AccountManager:bindAccount() + end) + end +end + +function AccountBindUI:refreshAccountInfo() + if Platform:isIosPlatform() then + if ModuleManager.AccountManager:getIsBinded() then + self.uiMap["account_bind_ui.title_bg_img.apple_sign_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACCOUNT_ALREADY_BINDED_DESC)) + else + self.uiMap["account_bind_ui.title_bg_img.apple_sign_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.BIND_ACCOUNT_DESC)) + end + else + if ModuleManager.AccountManager:getIsBinded() then + self.uiMap["account_bind_ui.title_bg_img.google_sign_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACCOUNT_ALREADY_BINDED_DESC)) + else + self.uiMap["account_bind_ui.title_bg_img.google_sign_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.BIND_ACCOUNT_DESC)) + end end end diff --git a/lua/app/ui/game_setting/game_setting_ui.lua b/lua/app/ui/game_setting/game_setting_ui.lua index e79fa846..5a073e7c 100644 --- a/lua/app/ui/game_setting/game_setting_ui.lua +++ b/lua/app/ui/game_setting/game_setting_ui.lua @@ -47,31 +47,8 @@ function GameSettingUI:_display() end function GameSettingUI:initLoginBtn() - self.uiMap["game_setting_ui.bg.google_sign_btn"]:addClickListener(function() - if ModuleManager.AccountManager:getIsBinded() then - GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.ACCOUNT_ALREADY_BINDED_DESC)) - return - end - ModuleManager.AccountManager:bindAccount() - end) - - self.uiMap["game_setting_ui.bg.google_switch_btn"]:addClickListener(function() - if ModuleManager.AccountManager:getIsBinded() then - ModuleManager.AccountManager:changeAccount() - else - local params = { - content = I18N:getGlobalText(I18N.GlobalConst.CHANGE_ACCOUNT_TIPS_DESC), - boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL, - okText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK), - okFunc = function() - ModuleManager.AccountManager:changeAccount() - end - } - GFunc.showMessageBox(params) - end - end) - self.uiMap["game_setting_ui.bg.google_switch_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.CHANGE_ACCOUNT_DESC)) - + self:initGoogleLoginBtn() + self:initAppleLoginBtn() local deleteBtn = self.uiMap["game_setting_ui.bg.delete_btn"] deleteBtn:addClickListener(function() ModuleManager.AccountManager:showDeleteUI() @@ -79,6 +56,73 @@ function GameSettingUI:initLoginBtn() self:refreshAccountInfo() end +function GameSettingUI:initGoogleLoginBtn() + if Platform:isIosPlatform() then + self.uiMap["game_setting_ui.bg.google_sign_btn"]:setVisible(false) + self.uiMap["game_setting_ui.bg.google_switch_btn"]:setVisible(false) + else + self.uiMap["game_setting_ui.bg.google_sign_btn"]:setVisible(true) + self.uiMap["game_setting_ui.bg.google_sign_btn"]:addClickListener(function() + if ModuleManager.AccountManager:getIsBinded() then + GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.ACCOUNT_ALREADY_BINDED_DESC)) + return + end + ModuleManager.AccountManager:bindAccount() + end) + + self.uiMap["game_setting_ui.bg.google_switch_btn"]:setVisible(true) + self.uiMap["game_setting_ui.bg.google_switch_btn"]:addClickListener(function() + if ModuleManager.AccountManager:getIsBinded() then + ModuleManager.AccountManager:changeAccount() + else + local params = { + content = I18N:getGlobalText(I18N.GlobalConst.CHANGE_ACCOUNT_TIPS_DESC), + boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL, + okText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK), + okFunc = function() + ModuleManager.AccountManager:changeAccount() + end + } + GFunc.showMessageBox(params) + end + end) + self.uiMap["game_setting_ui.bg.google_switch_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.CHANGE_ACCOUNT_DESC)) + end +end + +function GameSettingUI:initAppleLoginBtn() + if Platform:isIosPlatform() then + self.uiMap["game_setting_ui.bg.apple_sign_btn"]:setVisible(true) + self.uiMap["game_setting_ui.bg.apple_sign_btn"]:addClickListener(function() + if ModuleManager.AccountManager:getIsBinded() then + GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.ACCOUNT_ALREADY_BINDED_DESC)) + return + end + ModuleManager.AccountManager:bindAccount() + end) + self.uiMap["game_setting_ui.bg.apple_switch_btn"]:setVisible(true) + self.uiMap["game_setting_ui.bg.apple_switch_btn"]:addClickListener(function() + if ModuleManager.AccountManager:getIsBinded() then + ModuleManager.AccountManager:changeAccount() + else + local params = { + content = I18N:getGlobalText(I18N.GlobalConst.CHANGE_ACCOUNT_TIPS_DESC), + boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL, + okText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK), + okFunc = function() + ModuleManager.AccountManager:changeAccount() + end + } + GFunc.showMessageBox(params) + end + end) + self.uiMap["game_setting_ui.bg.apple_switch_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.CHANGE_ACCOUNT_DESC)) + else + self.uiMap["game_setting_ui.bg.apple_sign_btn"]:setVisible(false) + self.uiMap["game_setting_ui.bg.apple_switch_btn"]:setVisible(false) + end +end + function GameSettingUI:_addListeners() self.uiMap["game_setting_ui.bg.close_btn"]:addClickListener(function() self:closeUI() @@ -149,10 +193,18 @@ function GameSettingUI:refreshVoice() end function GameSettingUI:refreshAccountInfo() - if ModuleManager.AccountManager:getIsBinded() then - self.uiMap["game_setting_ui.bg.google_sign_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACCOUNT_ALREADY_BINDED_DESC)) + if Platform:isIosPlatform() then + if ModuleManager.AccountManager:getIsBinded() then + self.uiMap["game_setting_ui.bg.apple_sign_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACCOUNT_ALREADY_BINDED_DESC)) + else + self.uiMap["game_setting_ui.bg.apple_sign_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.BIND_ACCOUNT_DESC)) + end else - self.uiMap["game_setting_ui.bg.google_sign_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.BIND_ACCOUNT_DESC)) + if ModuleManager.AccountManager:getIsBinded() then + self.uiMap["game_setting_ui.bg.google_sign_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACCOUNT_ALREADY_BINDED_DESC)) + else + self.uiMap["game_setting_ui.bg.google_sign_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.BIND_ACCOUNT_DESC)) + end end end