- 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>
69 lines
2.1 KiB
Dart
69 lines
2.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import '../../../core/auth/auth_bloc.dart';
|
|
|
|
class DisplayNameScreen extends StatefulWidget {
|
|
const DisplayNameScreen({super.key});
|
|
|
|
@override
|
|
State<DisplayNameScreen> createState() => _DisplayNameScreenState();
|
|
}
|
|
|
|
class _DisplayNameScreenState extends State<DisplayNameScreen> {
|
|
final _controller = TextEditingController();
|
|
|
|
@override
|
|
void dispose() {
|
|
_controller.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
void _submit() {
|
|
final name = _controller.text.trim();
|
|
if (name.isEmpty) return;
|
|
context.read<AuthBloc>().add(AnonymousLoginRequested(name));
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocListener<AuthBloc, AuthState>(
|
|
listener: (context, state) {
|
|
if (state is AuthError) {
|
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(state.message)));
|
|
}
|
|
},
|
|
child: Scaffold(
|
|
appBar: AppBar(title: const Text('Siapa namamu?')),
|
|
body: Padding(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
const Text('Pilih nama yang ingin kamu gunakan. Nama ini tidak akan terlihat oleh siapapun selain mitra kamu.'),
|
|
const SizedBox(height: 24),
|
|
TextField(
|
|
controller: _controller,
|
|
decoration: const InputDecoration(
|
|
labelText: 'Nama panggilan',
|
|
border: OutlineInputBorder(),
|
|
),
|
|
textInputAction: TextInputAction.done,
|
|
onSubmitted: (_) => _submit(),
|
|
),
|
|
const SizedBox(height: 24),
|
|
BlocBuilder<AuthBloc, AuthState>(
|
|
builder: (context, state) => ElevatedButton(
|
|
onPressed: state is AuthLoading ? null : _submit,
|
|
child: state is AuthLoading
|
|
? const CircularProgressIndicator()
|
|
: const Text('Lanjut'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|