implemented a customizable chat background system with support for patterns, solid colors, and gallery images; added a dedicated settings page with live preview and adjustable blur/dim effects, updated the image cropper to support flexible aspect ratios for wallpapers, and integrated file cleanup logic during account logout.
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'chat_background_settings.g.dart';
|
||||
|
||||
/// Source of the chat background.
|
||||
/// * [pattern] — the bundled tiled asset (legacy default, dark-mode inverted)
|
||||
/// * [image] — a user-picked image stored at [AppPaths.chatBackgroundImage]
|
||||
/// * [color] — a single solid colour ([ChatBackgroundSettings.colorValue])
|
||||
/// * [none] — plain theme surface colour
|
||||
enum ChatBackgroundType { pattern, image, color, none }
|
||||
|
||||
/// How [ChatBackgroundType.pattern]/[ChatBackgroundType.image] fill the area.
|
||||
enum ChatBackgroundFit { cover, tile, center }
|
||||
|
||||
@JsonSerializable()
|
||||
class ChatBackgroundSettings {
|
||||
ChatBackgroundType type;
|
||||
ChatBackgroundFit fit;
|
||||
|
||||
/// ARGB colour for [ChatBackgroundType.color]; null until the user picks one.
|
||||
int? colorValue;
|
||||
|
||||
/// Monotonically increasing cache-buster. The image lives under a constant
|
||||
/// filename, so Flutter's [ImageCache] can't tell a replacement apart — this
|
||||
/// counter drives a [ValueKey] that forces a fresh subtree after a swap.
|
||||
int imageVersion;
|
||||
|
||||
/// Strength of the black dim overlay drawn above the background (0..1).
|
||||
double dim;
|
||||
|
||||
/// Gaussian blur sigma applied to the pattern/image layer (0..~25).
|
||||
double blur;
|
||||
|
||||
ChatBackgroundSettings({
|
||||
required this.type,
|
||||
required this.fit,
|
||||
required this.colorValue,
|
||||
required this.imageVersion,
|
||||
required this.dim,
|
||||
required this.blur,
|
||||
});
|
||||
|
||||
factory ChatBackgroundSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$ChatBackgroundSettingsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$ChatBackgroundSettingsToJson(this);
|
||||
}
|
||||
Reference in New Issue
Block a user