Files
AIOA/mobile/lib/core/auth/login_page.dart
T
2026-07-18 19:20:07 +08:00

75 lines
2.8 KiB
Dart

import 'package:aioa_mobile/app/theme.dart';
import 'package:aioa_mobile/core/auth/auth_session_controller.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
class LoginPage extends ConsumerWidget {
const LoginPage({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final auth = ref.watch(authSessionProvider);
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: buildAioaTheme(),
home: Scaffold(
body: SafeArea(
child: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 420),
child: Padding(
padding: const EdgeInsets.all(28),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const CircleAvatar(
radius: 36,
child: Icon(Icons.apartment_rounded, size: 38),
),
const SizedBox(height: 20),
Text(
'AIOA',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.headlineMedium
?.copyWith(fontWeight: FontWeight.w900),
),
const SizedBox(height: 8),
const Text('使用企业账号安全登录', textAlign: TextAlign.center),
if (auth.hasError) ...[
const SizedBox(height: 16),
Text(
'登录失败:${auth.error}',
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).colorScheme.error,
),
),
],
const SizedBox(height: 28),
FilledButton.icon(
onPressed: auth.isLoading
? null
: ref.read(authSessionProvider.notifier).login,
icon: auth.isLoading
? const SizedBox.square(
dimension: 18,
child: CircularProgressIndicator(strokeWidth: 2),
)
: const Icon(Icons.login),
label: const Padding(
padding: EdgeInsets.symmetric(vertical: 14),
child: Text('Keycloak 登录'),
),
),
],
),
),
),
),
),
),
);
}
}