mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 04:57:23 +00:00
improve login
This commit is contained in:
@@ -167,7 +167,11 @@
|
||||
"Failed to register URL scheme.": "注册URL协议失败",
|
||||
"Retry": "重试",
|
||||
"Network": "网络",
|
||||
"Save to gallery": "保存到相册"
|
||||
"Save to gallery": "保存到相册",
|
||||
"Choose a way to login": "选择登录方式",
|
||||
"Use Webview: you cannot sign in with Google.": "使用Webview: 无法使用Google登录",
|
||||
"Use an external browser: You can sign in using Google. However, some browsers may not be compatible with the application": "使用外部浏览器: 可以使用Google登录. 但是, 一些浏览器可能与应用程序不兼容",
|
||||
"External browser": "外部浏览器"
|
||||
},
|
||||
"zh_TW": {
|
||||
"Search": "搜索",
|
||||
@@ -337,6 +341,10 @@
|
||||
"Failed to register URL scheme.": "註冊URL協議失敗",
|
||||
"Retry": "重試",
|
||||
"Network": "網絡",
|
||||
"Save to gallery": "保存到相冊"
|
||||
"Save to gallery": "保存到相冊",
|
||||
"Choose a way to login": "選擇登錄方式",
|
||||
"Use Webview: you cannot sign in with Google.": "使用Webview: 無法使用Google登錄",
|
||||
"Use an external browser: You can sign in using Google. However, some browsers may not be compatible with the application": "使用外部瀏覽器: 可以使用Google登錄. 但是, 一些瀏覽器可能與應用程序不兼容",
|
||||
"External browser": "外部瀏覽器"
|
||||
}
|
||||
}
|
@@ -42,13 +42,13 @@ class FluentButton extends BaseButton {
|
||||
|
||||
final double? width;
|
||||
|
||||
static const _kFluentButtonPadding = 24;
|
||||
static const _kFluentButtonPadding = 12.0;
|
||||
|
||||
@override
|
||||
Widget buildNormal(BuildContext context) {
|
||||
Widget child = this.child;
|
||||
if (width != null) {
|
||||
child = child.fixWidth(width! - _kFluentButtonPadding);
|
||||
child = child.fixWidth(width! - _kFluentButtonPadding * 2);
|
||||
}
|
||||
return FilledButton(
|
||||
onPressed: onPressed,
|
||||
@@ -59,15 +59,18 @@ class FluentButton extends BaseButton {
|
||||
@override
|
||||
Widget buildLoading(BuildContext context) {
|
||||
Widget child = Center(
|
||||
widthFactor: 1,
|
||||
heightFactor: 1,
|
||||
child: const ProgressRing(
|
||||
strokeWidth: 1.6,
|
||||
).fixWidth(14).fixHeight(14),
|
||||
);
|
||||
if (width != null) {
|
||||
child = child.fixWidth(width!);
|
||||
child = child.fixWidth(width! - _kFluentButtonPadding * 2);
|
||||
}
|
||||
return Container(
|
||||
height: 26,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: _kFluentButtonPadding, vertical: 6.5),
|
||||
decoration: BoxDecoration(
|
||||
color: FluentTheme.of(context).inactiveBackgroundColor,
|
||||
borderRadius: BorderRadius.circular(4)),
|
||||
@@ -78,19 +81,20 @@ class FluentButton extends BaseButton {
|
||||
@override
|
||||
Widget buildDisabled(BuildContext context) {
|
||||
Widget child = Center(
|
||||
widthFactor: 1,
|
||||
heightFactor: 1,
|
||||
child: this.child,
|
||||
);
|
||||
if (width != null) {
|
||||
child = child.fixWidth(width!);
|
||||
child = child.fixWidth(width! - _kFluentButtonPadding * 2);
|
||||
}
|
||||
return Center(
|
||||
child: Container(
|
||||
height: 26,
|
||||
decoration: BoxDecoration(
|
||||
color: FluentTheme.of(context).inactiveBackgroundColor,
|
||||
borderRadius: BorderRadius.circular(4)),
|
||||
child: child,
|
||||
),
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: _kFluentButtonPadding, vertical: 6.5),
|
||||
decoration: BoxDecoration(
|
||||
color: FluentTheme.of(context).inactiveBackgroundColor,
|
||||
borderRadius: BorderRadius.circular(4)),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ class _LoginPageState extends State<LoginPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if(isLogging) {
|
||||
if (isLogging) {
|
||||
return buildLoading(context);
|
||||
} else if (!waitingForAuth) {
|
||||
return buildLogin(context);
|
||||
@@ -59,10 +59,10 @@ class _LoginPageState extends State<LoginPage> {
|
||||
children: [
|
||||
FluentButton(
|
||||
onPressed: onContinue,
|
||||
enabled: checked,
|
||||
enabled: checked,
|
||||
width: 96,
|
||||
child: Text("Continue".tl),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
@@ -176,6 +176,39 @@ class _LoginPageState extends State<LoginPage> {
|
||||
}
|
||||
|
||||
void onContinue() async {
|
||||
bool? useExternal;
|
||||
if (App.isMobile) {
|
||||
await showDialog(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (context) => ContentDialog(
|
||||
title: Text("Choose a way to login".tl),
|
||||
content: Text("${"Use Webview: you cannot sign in with Google.".tl}"
|
||||
"\n\n"
|
||||
"${"Use an external browser: You can sign in using Google. However, some browsers may not be compatible with the application".tl}"),
|
||||
actions: [
|
||||
Button(
|
||||
child: Text("Webview".tl),
|
||||
onPressed: () {
|
||||
useExternal = false;
|
||||
App.rootNavigatorKey.currentState!.pop();
|
||||
},
|
||||
),
|
||||
Button(
|
||||
child: Text("External browser".tl),
|
||||
onPressed: () {
|
||||
useExternal = true;
|
||||
App.rootNavigatorKey.currentState!.pop();
|
||||
},
|
||||
)
|
||||
]),
|
||||
);
|
||||
} else {
|
||||
useExternal = true;
|
||||
}
|
||||
if (useExternal == null) {
|
||||
return;
|
||||
}
|
||||
var url = await Network().generateWebviewUrl();
|
||||
onLink = (uri) {
|
||||
if (uri.scheme == "pixiv") {
|
||||
@@ -188,15 +221,18 @@ class _LoginPageState extends State<LoginPage> {
|
||||
setState(() {
|
||||
waitingForAuth = true;
|
||||
});
|
||||
if(App.isMobile && mounted) {
|
||||
context.to(() => WebviewPage(url, onNavigation: (req) {
|
||||
if(req.url.startsWith("pixiv://")) {
|
||||
App.rootNavigatorKey.currentState!.pop();
|
||||
onLink?.call(Uri.parse(req.url));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},));
|
||||
if (!useExternal! && mounted) {
|
||||
context.to(() => WebviewPage(
|
||||
url,
|
||||
onNavigation: (req) {
|
||||
if (req.url.startsWith("pixiv://")) {
|
||||
App.rootNavigatorKey.currentState!.pop();
|
||||
onLink?.call(Uri.parse(req.url));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
));
|
||||
} else {
|
||||
launchUrlString(url);
|
||||
}
|
||||
@@ -209,7 +245,7 @@ class _LoginPageState extends State<LoginPage> {
|
||||
});
|
||||
var res = await Network().loginWithCode(code);
|
||||
if (res.error) {
|
||||
if(mounted) {
|
||||
if (mounted) {
|
||||
context.showToast(message: res.errorMessage!);
|
||||
}
|
||||
setState(() {
|
||||
|
Reference in New Issue
Block a user