🧱 Add login with apple to web

This commit is contained in:
LittleSheep 2025-06-15 17:43:22 +08:00
parent b3786827ef
commit 484ded03b1
2 changed files with 29 additions and 21 deletions

View File

@ -565,6 +565,10 @@ class _LoginLookupScreen extends HookConsumerWidget {
try {
final credential = await SignInWithApple.getAppleIDCredential(
scopes: [AppleIDAuthorizationScopes.email],
webAuthenticationOptions: WebAuthenticationOptions(
clientId: 'dev.solsynth.solarpass',
redirectUri: Uri.parse('https://nt.solian.app/auth/callback/apple'),
),
);
if (context.mounted) showLoadingModal(context);
@ -591,6 +595,7 @@ class _LoginLookupScreen extends HookConsumerWidget {
if (context.mounted) Navigator.pop(context, true);
});
} catch (err) {
if (err is SignInWithAppleCredentialsException) return;
showErrorAlert(err);
} finally {
if (context.mounted) hideLoadingModal(context);
@ -626,13 +631,13 @@ class _LoginLookupScreen extends HookConsumerWidget {
onSubmitted: isBusy.value ? null : (_) => performNewTicket(),
).padding(horizontal: 7),
Row(
spacing: 4,
spacing: 6,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text("loginOr").tr().fontSize(11).opacity(0.85),
const Gap(8),
Spacer(),
IconButton.filled(
IconButton.filledTonal(
onPressed: () async {},
padding: EdgeInsets.zero,
icon: SvgPicture.asset(
@ -642,7 +647,7 @@ class _LoginLookupScreen extends HookConsumerWidget {
),
tooltip: 'Google',
),
IconButton.filled(
IconButton.filledTonal(
onPressed: () async {},
padding: EdgeInsets.zero,
icon: SvgPicture.asset(
@ -652,7 +657,7 @@ class _LoginLookupScreen extends HookConsumerWidget {
),
tooltip: 'Microsoft',
),
IconButton.filled(
IconButton.filledTonal(
onPressed: withApple,
padding: EdgeInsets.zero,
icon: SvgPicture.asset(
@ -663,7 +668,7 @@ class _LoginLookupScreen extends HookConsumerWidget {
tooltip: 'Apple Account',
),
],
).padding(horizontal: 8, top: 8, bottom: 4),
).padding(horizontal: 8, vertical: 8),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [

View File

@ -4,6 +4,7 @@ import 'package:gap/gap.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:island/models/post.dart';
import 'package:island/pods/network.dart';
import 'package:island/pods/userinfo.dart';
import 'package:island/services/responsive.dart';
import 'package:island/widgets/app_scaffold.dart';
import 'package:island/widgets/post/post_item.dart';
@ -29,6 +30,7 @@ class PostDetailScreen extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final post = ref.watch(postProvider(id));
final user = ref.watch(userInfoProvider);
final isWide = isWideScreen(context);
@ -58,24 +60,25 @@ class PostDetailScreen extends HookConsumerWidget {
SliverGap(MediaQuery.of(context).padding.bottom + 80),
],
),
Positioned(
bottom: 0,
left: 0,
right: 0,
child: Material(
elevation: 2,
child: PostQuickReply(
parent: post,
onPosted: () {
ref.invalidate(postRepliesNotifierProvider(id));
},
).padding(
bottom: MediaQuery.of(context).padding.bottom + 16,
top: 16,
horizontal: 16,
if (user.value != null)
Positioned(
bottom: 0,
left: 0,
right: 0,
child: Material(
elevation: 2,
child: PostQuickReply(
parent: post,
onPosted: () {
ref.invalidate(postRepliesNotifierProvider(id));
},
).padding(
bottom: MediaQuery.of(context).padding.bottom + 16,
top: 16,
horizontal: 16,
),
),
),
),
],
);
},