fix: Settings crash, photo preview before sending, incoming-content hardening

Settings crashed with a TypeError: the profile card passed a
SepotFingerprint object where the localized string formatter expects
a String (hidden behind a `dynamic` parameter). Also fixes RangeError
in avatar initials (empty names, double spaces) and switches initials
to grapheme clusters so emoji don't get split.

New photo preview screen: a captured or picked photo no longer sends
immediately — it opens in a preview with freehand drawing (7 colours,
undo), draggable text overlay, 90° rotation and a caption field.
Nothing leaves the device until Send is tapped.

Incoming-content hardening: decryption and content processing are now
separated in the delivery path. Once an envelope is decrypted the
ratchet has advanced, so redelivery can never help — permanently
malformed content (FormatException/TypeError) is acked and dropped
instead of poisoning the queue on every reconnect. Attachment metadata
now validates base64 of the crypto fields up front, and a corrupt
inline thumbnail no longer breaks bubble rendering.

PNG without real transparency (screenshots, edited photos) is now
re-encoded as JPEG — several times smaller on the wire.

Tests: 116 (new widget tests for Settings and the photo preview,
AttachmentMeta wire validation).
This commit is contained in:
Julius Joska
2026-07-13 08:15:01 +02:00
parent a60aaca326
commit 641d70b76e
24 changed files with 1299 additions and 41 deletions
@@ -12,6 +12,7 @@ import 'package:sepot/core/constants/app_constants.dart';
import 'package:sepot/core/l10n/error_messages.dart';
import 'package:sepot/core/l10n/l10n.dart';
import 'package:sepot/core/storage/secure_storage.dart';
import 'package:sepot/models/identity.dart';
import 'package:sepot/core/theme/app_theme.dart';
import 'package:sepot/providers/contacts_provider.dart';
import 'package:sepot/providers/conversations_provider.dart';
@@ -296,7 +297,7 @@ class SettingsScreen extends ConsumerWidget {
}
}
Widget _buildProfileCard(BuildContext context, dynamic identity) {
Widget _buildProfileCard(BuildContext context, LocalIdentity identity) {
return Container(
margin: const EdgeInsets.all(16),
padding: const EdgeInsets.all(20),
@@ -311,7 +312,9 @@ class SettingsScreen extends ConsumerWidget {
radius: 36,
backgroundColor: SepotColors.ember.withValues(alpha: 0.1),
child: Text(
identity.displayName.substring(0, 1).toUpperCase(),
identity.displayName.isEmpty
? '?'
: identity.displayName.characters.first.toUpperCase(),
style: const TextStyle(
fontFamily: kFontSans,
fontSize: 28,
@@ -324,7 +327,7 @@ class SettingsScreen extends ConsumerWidget {
Text(
identity.displayName,
style: const TextStyle(
fontFamily: kFontSans,
fontFamily: kFontSans,
fontSize: 20,
fontWeight: FontWeight.w600,
color: SepotColors.textPrimary,
@@ -352,7 +355,7 @@ class SettingsScreen extends ConsumerWidget {
),
const SizedBox(height: 8),
Text(
context.l10n.settingsFingerprint(identity.fingerprint),
context.l10n.settingsFingerprint(identity.fingerprint.display),
style: SepotTheme.cryptoText.copyWith(fontSize: 11),
),
],
@@ -368,7 +371,7 @@ class SettingsScreen extends ConsumerWidget {
child: Text(
title,
style: const TextStyle(
fontFamily: kFontSans,
fontFamily: kFontSans,
fontSize: 13,
fontWeight: FontWeight.w600,
color: SepotColors.textMuted,