- frame_suggestion_dialog: hide exception detail in error path, redesign candidate card as Card+InkWell with L2/L3 colored level badge (secondary vs primary), remove confidence % surface. - settings_screen: download tile gains state label + colored progress text, rounded LinearProgressIndicator, FilledButton.tonalIcon for resume/retry. _friendlyError() maps internal codes (network:/http /stream:/sha mismatch) to user-readable Korean. Opt-in/out dialogs reorganized with _Bullet rows; beta disclaimer reworded; _describe() friendlier copy. Polish only — no behavior change. analyze 0, 71 tests pass, APK 10.3s. Refs #215
140 lines
4.4 KiB
Dart
140 lines
4.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import '../../domain/ai/frame_candidate.dart';
|
|
import '../../domain/models/habit.dart';
|
|
import '../../state/ai_providers.dart';
|
|
|
|
/// Shows L2/L3 suggestion cards from suggestFrame. Returns the selected
|
|
/// FrameCandidate (with level + framedText) via Navigator.pop.
|
|
class FrameSuggestionDialog extends ConsumerWidget {
|
|
final SuggestFrameInput input;
|
|
const FrameSuggestionDialog({super.key, required this.input});
|
|
|
|
static Future<FrameCandidate?> show(
|
|
BuildContext context, {
|
|
required SuggestFrameInput input,
|
|
}) {
|
|
return showDialog<FrameCandidate>(
|
|
context: context,
|
|
builder: (_) => FrameSuggestionDialog(input: input),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final async = ref.watch(frameSuggestionsProvider(input));
|
|
return AlertDialog(
|
|
title: const Text('AI 제안'),
|
|
content: SizedBox(
|
|
width: 320,
|
|
child: async.when(
|
|
loading: () => const SizedBox(
|
|
height: 120,
|
|
child: Center(child: CircularProgressIndicator()),
|
|
),
|
|
error: (e, _) => const Padding(
|
|
padding: EdgeInsets.all(8),
|
|
child: Text(
|
|
'AI 제안을 받지 못했어요.\n직접 입력하셔도 괜찮습니다.',
|
|
),
|
|
),
|
|
data: (candidates) {
|
|
if (candidates.isEmpty) {
|
|
return Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
const Padding(
|
|
padding: EdgeInsets.all(8),
|
|
child: Text(
|
|
'더 구체적으로 입력해주시면 더 좋은 제안을 드릴 수 있어요.',
|
|
),
|
|
),
|
|
TextButton(
|
|
onPressed: () {
|
|
ref.invalidate(frameSuggestionsProvider(input));
|
|
},
|
|
child: const Text('다시 시도'),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
return Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
for (final c in candidates)
|
|
_CandidateCard(
|
|
candidate: c,
|
|
onTap: () => Navigator.of(context).pop(c),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
),
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
child: const Text('취소'),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
class _CandidateCard extends StatelessWidget {
|
|
final FrameCandidate candidate;
|
|
final VoidCallback onTap;
|
|
const _CandidateCard({required this.candidate, required this.onTap});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final scheme = Theme.of(context).colorScheme;
|
|
final isL3 = candidate.level == FrameLevel.l3;
|
|
final levelLabel = isL3 ? '정체성' : '조건부 긍정';
|
|
final levelCode = isL3 ? 'L3' : 'L2';
|
|
final levelColor = isL3 ? scheme.primary : scheme.secondary;
|
|
return Card(
|
|
margin: const EdgeInsets.symmetric(vertical: 4),
|
|
child: InkWell(
|
|
onTap: onTap,
|
|
borderRadius: BorderRadius.circular(8),
|
|
child: Padding(
|
|
padding: const EdgeInsets.fromLTRB(12, 10, 12, 12),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Container(
|
|
padding:
|
|
const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
|
decoration: BoxDecoration(
|
|
color: levelColor.withValues(alpha: 0.12),
|
|
borderRadius: BorderRadius.circular(4),
|
|
),
|
|
child: Text(
|
|
'$levelCode · $levelLabel',
|
|
style: TextStyle(
|
|
fontSize: 11,
|
|
color: levelColor,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 6),
|
|
Text(
|
|
candidate.framedText,
|
|
style: Theme.of(context).textTheme.bodyLarge,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|