Bestie Choice Sheet on home Mulai Curhat CTA. When the user has at least one prior session (bestieHistoryHasItemsProvider hits the chat- sessions history endpoint), the CTA opens a HaloBottomSheet with two cards: 'bestie yang udah kenal' -> /chat/history, 'bestie baru' -> /payment/entry. Empty history -> direct to /payment/entry. Bestie history list visual upgrade: HaloOrb (mitraId seed) + name + last-session date + topic pills + sessions count + ONLINE pill. Backend getCustomerHistory now returns topics, mitra_is_online, sessions_count in a single payload (no per-row presence round-trip). BestieOfflinePopup with two variants (returning | new_) replacing the legacy BestieUnavailableDialog. tanya admin ghost CTA on both variants opens the new TanyaAdminSheet. Stage 5's targeted-wait declined stub + Stage 7's chat-screen 409 stub + searching-screen call site all migrated to the real component. TanyaAdminSheet: HaloBottomSheet with WA + Telegram buttons, deeplinks fetched via supportHandlesProvider (CC-config-driven). url_launcher added to client_app; ios LSApplicationQueriesSchemes covers https/http/whatsapp/tg. Stage 2's OTP-blocked popup hubungi admin SnackBar stub also migrated to TanyaAdminSheet. Dev-only POST /internal/_test/seed-history-session lets Maestro 08 flow seed a history row before exercising the choice sheet. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
192 lines
7.2 KiB
Dart
192 lines
7.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import '../../../core/pairing/pairing_notifier.dart';
|
|
import '../../../core/theme/halo_tokens.dart';
|
|
import '../../../core/theme/widgets/widgets.dart';
|
|
import '../widgets/bestie_unavailable_dialog.dart';
|
|
|
|
/// Phase 4 Stage 5 — `SWaitingBestie` overlay.
|
|
///
|
|
/// Entry route: `/chat/waiting-targeted/:mitraId` — pushed from the chat
|
|
/// history "Curhat lagi" CTA after the targeted payment session is confirmed.
|
|
///
|
|
/// Three sub-states mapped from `pairingProvider`:
|
|
///
|
|
/// - `waiting` (PairingTargetedWaitingData) — orb + 20s countdown + cancel.
|
|
/// The countdown is purely cosmetic; the server owns the auto-reject timer.
|
|
/// - `accepted` (PairingBestieFoundData / PairingActiveData) — routes into
|
|
/// the chat screen immediately.
|
|
/// - `declined` (PairingTargetedUnavailableData) — shows the
|
|
/// [BestieOfflinePopup] returning variant; the popup may offer a
|
|
/// fallback-to-blast CTA when other besties are reachable.
|
|
class TargetedWaitingScreen extends ConsumerStatefulWidget {
|
|
final String mitraId;
|
|
const TargetedWaitingScreen({super.key, required this.mitraId});
|
|
|
|
@override
|
|
ConsumerState<TargetedWaitingScreen> createState() =>
|
|
_TargetedWaitingScreenState();
|
|
}
|
|
|
|
class _TargetedWaitingScreenState extends ConsumerState<TargetedWaitingScreen> {
|
|
bool _popupShown = false;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
ref.listenManual<PairingData>(pairingProvider, _onPairingState);
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
if (!mounted) return;
|
|
_onPairingState(null, ref.read(pairingProvider));
|
|
});
|
|
}
|
|
|
|
void _onPairingState(PairingData? prev, PairingData next) {
|
|
if (!mounted) return;
|
|
|
|
if (next is PairingBestieFoundData) {
|
|
context.go('/chat/session/${next.sessionId}', extra: next.mitraName);
|
|
return;
|
|
}
|
|
if (next is PairingActiveData) {
|
|
context.go('/chat/session/${next.sessionId}', extra: next.mitraName);
|
|
return;
|
|
}
|
|
if (next is PairingCancelledData) {
|
|
context.go('/home');
|
|
return;
|
|
}
|
|
if (next is PairingTargetedUnavailableData && !_popupShown) {
|
|
_popupShown = true;
|
|
// ignore: discarded_futures
|
|
BestieOfflinePopup.show(
|
|
context,
|
|
variant: BestieOfflineVariant.returning,
|
|
mitraName: next.mitraName,
|
|
paymentSessionId: next.paymentSessionId,
|
|
topicSensitivity: next.topicSensitivity,
|
|
).then((_) {
|
|
if (mounted) _popupShown = false;
|
|
});
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final state = ref.watch(pairingProvider);
|
|
|
|
final waiting = state is PairingTargetedWaitingData ? state : null;
|
|
final mitraName = waiting?.mitraName ?? 'bestie';
|
|
final secondsRemaining = waiting?.secondsRemaining ?? 0;
|
|
|
|
return PopScope(
|
|
// Targeted-wait is reachable directly from chat history; per the
|
|
// deep-link pop-fallback rule (project memory), we drop the user
|
|
// back to home if they swipe back rather than into a stale stack.
|
|
canPop: false,
|
|
onPopInvokedWithResult: (didPop, _) {
|
|
if (didPop) return;
|
|
ref.read(pairingProvider.notifier).cancelSearch();
|
|
},
|
|
child: Scaffold(
|
|
backgroundColor: HaloTokens.bg,
|
|
body: SafeArea(
|
|
child: Padding(
|
|
padding: const EdgeInsets.fromLTRB(
|
|
HaloSpacing.s24,
|
|
HaloSpacing.s24,
|
|
HaloSpacing.s24,
|
|
HaloSpacing.s24,
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Expanded(
|
|
child: Center(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
HaloOrb(
|
|
size: 120,
|
|
seed: mitraName.hashCode,
|
|
label: mitraName,
|
|
),
|
|
const SizedBox(height: HaloSpacing.s20),
|
|
const Text(
|
|
'◦ MENUNGGU JAWABAN ◦',
|
|
style: TextStyle(
|
|
fontFamily: HaloTokens.fontBody,
|
|
fontSize: 12,
|
|
fontWeight: FontWeight.w700,
|
|
letterSpacing: 1.6,
|
|
color: HaloTokens.brand,
|
|
),
|
|
),
|
|
const SizedBox(height: HaloSpacing.s8),
|
|
Text(
|
|
'lagi nungguin $mitraName',
|
|
textAlign: TextAlign.center,
|
|
style: const TextStyle(
|
|
fontFamily: HaloTokens.fontDisplay,
|
|
fontSize: 24,
|
|
height: 30 / 24,
|
|
fontWeight: FontWeight.w700,
|
|
color: HaloTokens.brandDark,
|
|
),
|
|
),
|
|
const SizedBox(height: HaloSpacing.s12),
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: HaloSpacing.s16,
|
|
vertical: HaloSpacing.s8,
|
|
),
|
|
decoration: BoxDecoration(
|
|
color: HaloTokens.brandSofter,
|
|
borderRadius: BorderRadius.circular(999),
|
|
border: Border.all(color: HaloTokens.brandSoft),
|
|
),
|
|
child: Text(
|
|
'${secondsRemaining}d',
|
|
style: const TextStyle(
|
|
fontFamily: HaloTokens.fontDisplay,
|
|
fontSize: 22,
|
|
fontWeight: FontWeight.w700,
|
|
color: HaloTokens.brandDark,
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: HaloSpacing.s12),
|
|
ConstrainedBox(
|
|
constraints: const BoxConstraints(maxWidth: 280),
|
|
child: const Text(
|
|
'kalau bestie nggak respon dalam 20 detik, kami bantu cariin yang lain.',
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
fontFamily: HaloTokens.fontBody,
|
|
fontSize: 13,
|
|
height: 20 / 13,
|
|
color: HaloTokens.inkSoft,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
HaloButton(
|
|
label: 'batalkan',
|
|
variant: HaloButtonVariant.ghost,
|
|
fullWidth: true,
|
|
onPressed: () =>
|
|
ref.read(pairingProvider.notifier).cancelSearch(),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|