- Backend: Fastify with two listeners (public + internal), routes, services, DB migration + seed - client_app: Flutter with BLoC, all auth screens (welcome, display name, register, OTP, force-register) - mitra_app: Flutter with BLoC, OTP-only login - control_center: React + Vite, email/password login, mitra/user management, anonymity settings - Docs: phase1 plan, API contract, client app mockup - CLAUDE.md and shared memory for all subprojects Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
94 lines
3.3 KiB
Dart
94 lines
3.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import '../../../core/auth/auth_bloc.dart';
|
|
|
|
class RegisterScreen extends StatefulWidget {
|
|
const RegisterScreen({super.key});
|
|
|
|
@override
|
|
State<RegisterScreen> createState() => _RegisterScreenState();
|
|
}
|
|
|
|
class _RegisterScreenState extends State<RegisterScreen> {
|
|
final _phoneController = TextEditingController();
|
|
|
|
@override
|
|
void dispose() {
|
|
_phoneController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocListener<AuthBloc, AuthState>(
|
|
listener: (context, state) {
|
|
if (state is AuthOtpSent) {
|
|
context.push('/auth/otp', extra: _phoneController.text.trim());
|
|
}
|
|
if (state is AuthError) {
|
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(state.message)));
|
|
}
|
|
},
|
|
child: Scaffold(
|
|
appBar: AppBar(title: const Text('Masuk / Daftar')),
|
|
body: Padding(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
BlocBuilder<AuthBloc, AuthState>(
|
|
builder: (context, state) => ElevatedButton.icon(
|
|
icon: const Icon(Icons.g_mobiledata),
|
|
onPressed: state is AuthLoading ? null
|
|
: () => context.read<AuthBloc>().add(GoogleLoginRequested()),
|
|
label: const Text('Lanjut dengan Google'),
|
|
),
|
|
),
|
|
const SizedBox(height: 12),
|
|
BlocBuilder<AuthBloc, AuthState>(
|
|
builder: (context, state) => ElevatedButton.icon(
|
|
icon: const Icon(Icons.apple),
|
|
onPressed: state is AuthLoading ? null
|
|
: () => context.read<AuthBloc>().add(AppleLoginRequested()),
|
|
label: const Text('Lanjut dengan Apple'),
|
|
),
|
|
),
|
|
const Padding(
|
|
padding: EdgeInsets.symmetric(vertical: 24),
|
|
child: Row(children: [
|
|
Expanded(child: Divider()),
|
|
Padding(padding: EdgeInsets.symmetric(horizontal: 12), child: Text('atau')),
|
|
Expanded(child: Divider()),
|
|
]),
|
|
),
|
|
TextField(
|
|
controller: _phoneController,
|
|
decoration: const InputDecoration(
|
|
labelText: 'Nomor HP',
|
|
hintText: '+628xxxxxxxxxx',
|
|
border: OutlineInputBorder(),
|
|
),
|
|
keyboardType: TextInputType.phone,
|
|
),
|
|
const SizedBox(height: 12),
|
|
BlocBuilder<AuthBloc, AuthState>(
|
|
builder: (context, state) => ElevatedButton(
|
|
onPressed: state is AuthLoading ? null : () {
|
|
final phone = _phoneController.text.trim();
|
|
if (phone.isEmpty) return;
|
|
context.read<AuthBloc>().add(PhoneOtpRequested(phone));
|
|
},
|
|
child: state is AuthLoading
|
|
? const CircularProgressIndicator()
|
|
: const Text('Kirim OTP'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|