Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/app/router/app_router.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion lib/features/home/domain/entities/translation_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ class TranslationResult {
final bool isBookmarked;
final DateTime timestamp;

TranslationResult copyWith({int? id, bool? isBookmarked, String? aiResponse}) {
TranslationResult copyWith({
int? id,
bool? isBookmarked,
String? aiResponse,
}) {
return TranslationResult(
id: id ?? this.id,
inputText: inputText,
Expand Down
11 changes: 4 additions & 7 deletions lib/features/home/presentation/providers/streak_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@ Future<int> streak(Ref ref) async {
}

int _computeStreak(List<Map<String, dynamic>> rows) {
final Set<String> completionDates = rows
.map((Map<String, dynamic> r) {
final DateTime d =
DateTime.parse(r['completed_at'] as String).toLocal();
return _dateKey(d);
})
.toSet();
final Set<String> completionDates = rows.map((Map<String, dynamic> r) {
final DateTime d = DateTime.parse(r['completed_at'] as String).toLocal();
return _dateKey(d);
}).toSet();

if (completionDates.isEmpty) return 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,19 @@ class TranslateSketchpadController extends Notifier<TranslateSketchpadState> {
.analyzeImage(imageBytes, prompt: prompt)) {
buffer.write(chunk);
final String cleaned = cleanAssistantOutput(buffer.toString());
final String displayResponse =
GemmaPrompts.parseThinkBlock(cleaned).answer;
final String displayResponse = GemmaPrompts.parseThinkBlock(
cleaned,
).answer;
state = state.copyWith(
aiBusy: true,
aiResponse: displayResponse,
aiSource: TranslateAiResultSource.offline,
);
}
final String cleaned = cleanAssistantOutput(buffer.toString());
final String displayResponse =
GemmaPrompts.parseThinkBlock(cleaned).answer;
final String displayResponse = GemmaPrompts.parseThinkBlock(
cleaned,
).answer;
state = state.copyWith(
aiBusy: false,
aiResponse: displayResponse,
Expand Down Expand Up @@ -166,17 +168,19 @@ class TranslateSketchpadController extends Notifier<TranslateSketchpadState> {
await for (final String chunk in stream) {
buffer.write(chunk);
final String cleaned = cleanAssistantOutput(buffer.toString());
final String displayResponse =
GemmaPrompts.parseThinkBlock(cleaned).answer;
final String displayResponse = GemmaPrompts.parseThinkBlock(
cleaned,
).answer;
state = state.copyWith(
aiBusy: true,
aiResponse: displayResponse,
aiSource: source,
);
}
final String cleaned = cleanAssistantOutput(buffer.toString());
final String displayResponse =
GemmaPrompts.parseThinkBlock(cleaned).answer;
final String displayResponse = GemmaPrompts.parseThinkBlock(
cleaned,
).answer;
state = state.copyWith(
aiBusy: false,
aiResponse: displayResponse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ class TranslationHistoryNotifier
saved = await _ds.insert(result);
final List<TranslationResult> current =
state.value ?? <TranslationResult>[];
state = AsyncData<List<TranslationResult>>(
<TranslationResult>[saved, ...current],
);
state = AsyncData<List<TranslationResult>>(<TranslationResult>[
saved,
...current,
]);
} catch (_) {
// Local save failure is non-fatal
}
Expand Down Expand Up @@ -104,9 +105,10 @@ class TranslationHistoryNotifier
await _ds.updateAiResponse(latest.id!, text);
} catch (_) {}
}
state = AsyncData<List<TranslationResult>>(
<TranslationResult>[updated, ...current.skip(1)],
);
state = AsyncData<List<TranslationResult>>(<TranslationResult>[
updated,
...current.skip(1),
]);
}

Future<void> clearHistory() async {
Expand Down Expand Up @@ -156,17 +158,19 @@ class TranslationHistoryNotifier
.order('created_at', ascending: false)
.limit(100);

return rows.map((dynamic row) {
final Map<String, dynamic> r = row as Map<String, dynamic>;
return TranslationResult(
inputText: r['input_text'] as String? ?? '',
baybayinText: r['output_baybayin'] as String? ?? '',
latinText: r['output_latin'] as String? ?? '',
direction: r['direction'] as String? ?? 'latin_to_baybayin',
aiResponse: r['ai_response'] as String? ?? '',
isBookmarked: r['is_bookmarked'] as bool? ?? false,
timestamp: DateTime.parse(r['created_at'] as String),
);
}).toList(growable: false);
return rows
.map((dynamic row) {
final Map<String, dynamic> r = row as Map<String, dynamic>;
return TranslationResult(
inputText: r['input_text'] as String? ?? '',
baybayinText: r['output_baybayin'] as String? ?? '',
latinText: r['output_latin'] as String? ?? '',
direction: r['direction'] as String? ?? 'latin_to_baybayin',
aiResponse: r['ai_response'] as String? ?? '',
isBookmarked: r['is_bookmarked'] as bool? ?? false,
timestamp: DateTime.parse(r['created_at'] as String),
);
})
.toList(growable: false);
}
}
106 changes: 46 additions & 60 deletions lib/features/home/presentation/screens/butty_data_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,20 @@ class _HeroBanner extends StatelessWidget {
Positioned(
right: -10,
bottom: -8,
child: Image.asset(
'assets/brand/ButtyTextBubble.webp',
height: 150,
fit: BoxFit.fitHeight,
)
.animate(delay: 100.ms)
.slideX(
begin: 0.25,
end: 0,
duration: 420.ms,
curve: Curves.easeOutCubic,
)
.fadeIn(duration: 320.ms),
child:
Image.asset(
'assets/brand/ButtyTextBubble.webp',
height: 150,
fit: BoxFit.fitHeight,
)
.animate(delay: 100.ms)
.slideX(
begin: 0.25,
end: 0,
duration: 420.ms,
curve: Curves.easeOutCubic,
)
.fadeIn(duration: 320.ms),
),
Padding(
padding: const EdgeInsets.fromLTRB(20, 56, 150, 18),
Expand Down Expand Up @@ -147,18 +148,17 @@ class _HeroBanner extends StatelessWidget {
),
const SizedBox(height: 8),
Text(
'Tara, ayusin natin!\nYour chats and what I remember about you.',
style: TextStyle(
fontSize: 14.5,
fontWeight: FontWeight.w700,
color: cs.onPrimary,
height: 1.4,
),
).animate(delay: 80.ms).fadeIn(duration: 300.ms).slideY(
begin: 0.1,
end: 0,
duration: 300.ms,
),
'Tara, ayusin natin!\nYour chats and what I remember about you.',
style: TextStyle(
fontSize: 14.5,
fontWeight: FontWeight.w700,
color: cs.onPrimary,
height: 1.4,
),
)
.animate(delay: 80.ms)
.fadeIn(duration: 300.ms)
.slideY(begin: 0.1, end: 0, duration: 300.ms),
],
),
),
Expand Down Expand Up @@ -575,10 +575,7 @@ MarkdownStyleSheet _markdownStyle(BuildContext context, TextStyle base) {
strong: base.copyWith(fontWeight: FontWeight.w700),
em: base.copyWith(fontStyle: FontStyle.italic),
listBullet: base,
a: base.copyWith(
color: cs.primary,
decoration: TextDecoration.underline,
),
a: base.copyWith(color: cs.primary, decoration: TextDecoration.underline),
code: base.copyWith(
fontFamily: 'monospace',
fontSize: 13,
Expand Down Expand Up @@ -638,14 +635,16 @@ class _MemorySection extends ConsumerWidget {
);
if (draft == null) return;
final DateTime now = DateTime.now();
await ref.read(chatMemoryNotifierProvider.notifier).addFacts(<ChatMemoryFact>[
ChatMemoryFact(
factType: draft.factType,
content: draft.content,
createdAt: now,
lastReferencedAt: now,
),
]);
await ref
.read(chatMemoryNotifierProvider.notifier)
.addFacts(<ChatMemoryFact>[
ChatMemoryFact(
factType: draft.factType,
content: draft.content,
createdAt: now,
lastReferencedAt: now,
),
]);
}
}

Expand Down Expand Up @@ -711,15 +710,14 @@ class _MemoryBody extends ConsumerWidget {
}
final _MemoryFactDraft? draft = result.draft;
if (draft == null) return;
await ref.read(chatMemoryNotifierProvider.notifier).updateFact(
await ref
.read(chatMemoryNotifierProvider.notifier)
.updateFact(
f.copyWith(factType: draft.factType, content: draft.content),
);
}

Future<void> _confirmClearMemory(
BuildContext context,
WidgetRef ref,
) async {
Future<void> _confirmClearMemory(BuildContext context, WidgetRef ref) async {
final bool? confirmed = await showDialog<bool>(
context: context,
builder: (BuildContext ctx) {
Expand Down Expand Up @@ -833,9 +831,7 @@ class _MemoryFactDraft {

class _EditFactResult {
const _EditFactResult.update(this.draft) : delete = false;
const _EditFactResult.delete()
: draft = null,
delete = true;
const _EditFactResult.delete() : draft = null, delete = true;
final _MemoryFactDraft? draft;
final bool delete;
}
Expand Down Expand Up @@ -886,10 +882,8 @@ class _EditFactDialogState extends State<_EditFactDialog> {
),
items: _memoryTypes
.map(
(String t) => DropdownMenuItem<String>(
value: t,
child: Text(t),
),
(String t) =>
DropdownMenuItem<String>(value: t, child: Text(t)),
)
.toList(growable: false),
onChanged: (String? v) {
Expand Down Expand Up @@ -993,9 +987,7 @@ class _SectionCard extends StatelessWidget {
color: cs.primaryContainer,
shape: BoxShape.circle,
),
child: ClipOval(
child: Image.asset(mascot, fit: BoxFit.cover),
),
child: ClipOval(child: Image.asset(mascot, fit: BoxFit.cover)),
),
const SizedBox(width: 10),
Expanded(
Expand Down Expand Up @@ -1026,10 +1018,7 @@ class _SectionCard extends StatelessWidget {
],
),
const SizedBox(height: 12),
Padding(
padding: const EdgeInsets.only(right: 6),
child: child,
),
Padding(padding: const EdgeInsets.only(right: 6), child: child),
],
),
);
Expand Down Expand Up @@ -1114,10 +1103,7 @@ class _ErrorBlock extends StatelessWidget {
final ColorScheme cs = Theme.of(context).colorScheme;
return Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Text(
message,
style: TextStyle(color: cs.error, fontSize: 12.5),
),
child: Text(message, style: TextStyle(color: cs.error, fontSize: 12.5)),
);
}
}
Loading
Loading