Add mitra online/offline status with heartbeat-based auto-offline, customer-mitra pairing via Valkey pub/sub blast, session management, and control center dashboard with real-time stats. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
67 lines
2.3 KiB
Dart
67 lines
2.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';
|
|
import '../../core/pairing/pairing_bloc.dart';
|
|
|
|
class HomeScreen extends StatelessWidget {
|
|
const HomeScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocListener<PairingBloc, PairingState>(
|
|
listener: (context, state) {
|
|
if (state is PairingSearching) {
|
|
context.go('/chat/searching');
|
|
} else if (state is PairingNoBestie) {
|
|
context.go('/chat/no-bestie');
|
|
} else if (state is PairingError) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(content: Text(state.message)),
|
|
);
|
|
}
|
|
},
|
|
child: BlocBuilder<AuthBloc, AuthState>(
|
|
builder: (context, state) {
|
|
final displayName = state is AuthAuthenticated
|
|
? state.profile['display_name'] as String
|
|
: state is AuthAnonymous
|
|
? state.displayName
|
|
: '';
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Halo Bestie'),
|
|
actions: [
|
|
IconButton(
|
|
icon: const Icon(Icons.logout),
|
|
onPressed: () => context.read<AuthBloc>().add(LogoutRequested()),
|
|
),
|
|
],
|
|
),
|
|
body: Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(32),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text('Halo, $displayName!', style: const TextStyle(fontSize: 24)),
|
|
const SizedBox(height: 48),
|
|
ElevatedButton(
|
|
style: ElevatedButton.styleFrom(
|
|
padding: const EdgeInsets.symmetric(horizontal: 48, vertical: 16),
|
|
),
|
|
onPressed: () => context.read<PairingBloc>().add(RequestPairing()),
|
|
child: const Text('Mulai Curhat', style: TextStyle(fontSize: 18)),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|