2026-01-19 14:56:39 +08:00
|
|
|
import 'package:flutter/material.dart';
|
2026-01-19 15:45:46 +08:00
|
|
|
import 'package:go_router/go_router.dart';
|
2026-01-19 14:56:39 +08:00
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:phone_login/auth/auth_state.dart';
|
|
|
|
|
|
2026-01-19 15:38:36 +08:00
|
|
|
class HomeScreen extends StatelessWidget {
|
2026-01-19 14:56:39 +08:00
|
|
|
const HomeScreen({super.key});
|
|
|
|
|
|
|
|
|
|
@override
|
2026-01-19 15:38:36 +08:00
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: AppBar(title: const Text('Home')),
|
|
|
|
|
body: Consumer<AuthState>(
|
|
|
|
|
builder: (context, authState, child) {
|
|
|
|
|
return authState.isLoggedIn
|
|
|
|
|
? const _LoggedInView()
|
|
|
|
|
: const _LoggedOutView();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-01-19 14:56:39 +08:00
|
|
|
}
|
|
|
|
|
|
2026-01-19 15:38:36 +08:00
|
|
|
class _LoggedInView extends StatelessWidget {
|
|
|
|
|
const _LoggedInView();
|
2026-01-19 14:56:39 +08:00
|
|
|
|
2026-01-19 15:38:36 +08:00
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return const Center(child: Text('Logged In'));
|
2026-01-19 14:56:39 +08:00
|
|
|
}
|
2026-01-19 15:38:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _LoggedOutView extends StatelessWidget {
|
|
|
|
|
const _LoggedOutView();
|
2026-01-19 14:56:39 +08:00
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2026-01-19 15:45:46 +08:00
|
|
|
return Center(
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
const Icon(Icons.lock, size: 100, color: Colors.grey),
|
|
|
|
|
const SizedBox(height: 20),
|
|
|
|
|
Text('Welcome!', style: Theme.of(context).textTheme.headlineMedium),
|
|
|
|
|
const SizedBox(height: 10),
|
|
|
|
|
const Text(
|
|
|
|
|
'Please log in to continue.',
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
style: TextStyle(color: Colors.grey),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 30),
|
|
|
|
|
ElevatedButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
context.go('/phone');
|
|
|
|
|
},
|
|
|
|
|
child: const Text('Login'),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
2026-01-19 14:56:39 +08:00
|
|
|
}
|
|
|
|
|
}
|