Compare commits
4 Commits
c003f27b9a
...
01fa228e45
| Author | SHA1 | Date | |
|---|---|---|---|
|
01fa228e45
|
|||
|
1e71ad33a6
|
|||
|
92c0260ecd
|
|||
|
0a161ad255
|
@@ -10,7 +10,6 @@ sealed class SnSticker with _$SnSticker {
|
|||||||
const factory SnSticker({
|
const factory SnSticker({
|
||||||
required String id,
|
required String id,
|
||||||
required String slug,
|
required String slug,
|
||||||
required String imageId,
|
|
||||||
required SnCloudFile image,
|
required SnCloudFile image,
|
||||||
required String packId,
|
required String packId,
|
||||||
required SnStickerPack? pack,
|
required SnStickerPack? pack,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ T _$identity<T>(T value) => value;
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$SnSticker {
|
mixin _$SnSticker {
|
||||||
|
|
||||||
String get id; String get slug; String get imageId; SnCloudFile get image; String get packId; SnStickerPack? get pack; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt;
|
String get id; String get slug; SnCloudFile get image; String get packId; SnStickerPack? get pack; DateTime get createdAt; DateTime get updatedAt; DateTime? get deletedAt;
|
||||||
/// Create a copy of SnSticker
|
/// Create a copy of SnSticker
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@@ -28,16 +28,16 @@ $SnStickerCopyWith<SnSticker> get copyWith => _$SnStickerCopyWithImpl<SnSticker>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is SnSticker&&(identical(other.id, id) || other.id == id)&&(identical(other.slug, slug) || other.slug == slug)&&(identical(other.imageId, imageId) || other.imageId == imageId)&&(identical(other.image, image) || other.image == image)&&(identical(other.packId, packId) || other.packId == packId)&&(identical(other.pack, pack) || other.pack == pack)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is SnSticker&&(identical(other.id, id) || other.id == id)&&(identical(other.slug, slug) || other.slug == slug)&&(identical(other.image, image) || other.image == image)&&(identical(other.packId, packId) || other.packId == packId)&&(identical(other.pack, pack) || other.pack == pack)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType,id,slug,imageId,image,packId,pack,createdAt,updatedAt,deletedAt);
|
int get hashCode => Object.hash(runtimeType,id,slug,image,packId,pack,createdAt,updatedAt,deletedAt);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'SnSticker(id: $id, slug: $slug, imageId: $imageId, image: $image, packId: $packId, pack: $pack, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)';
|
return 'SnSticker(id: $id, slug: $slug, image: $image, packId: $packId, pack: $pack, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ abstract mixin class $SnStickerCopyWith<$Res> {
|
|||||||
factory $SnStickerCopyWith(SnSticker value, $Res Function(SnSticker) _then) = _$SnStickerCopyWithImpl;
|
factory $SnStickerCopyWith(SnSticker value, $Res Function(SnSticker) _then) = _$SnStickerCopyWithImpl;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
String id, String slug, String imageId, SnCloudFile image, String packId, SnStickerPack? pack, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt
|
String id, String slug, SnCloudFile image, String packId, SnStickerPack? pack, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -65,11 +65,10 @@ class _$SnStickerCopyWithImpl<$Res>
|
|||||||
|
|
||||||
/// Create a copy of SnSticker
|
/// Create a copy of SnSticker
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? slug = null,Object? imageId = null,Object? image = null,Object? packId = null,Object? pack = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) {
|
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? slug = null,Object? image = null,Object? packId = null,Object? pack = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) {
|
||||||
return _then(_self.copyWith(
|
return _then(_self.copyWith(
|
||||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||||
as String,slug: null == slug ? _self.slug : slug // ignore: cast_nullable_to_non_nullable
|
as String,slug: null == slug ? _self.slug : slug // ignore: cast_nullable_to_non_nullable
|
||||||
as String,imageId: null == imageId ? _self.imageId : imageId // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,image: null == image ? _self.image : image // ignore: cast_nullable_to_non_nullable
|
as String,image: null == image ? _self.image : image // ignore: cast_nullable_to_non_nullable
|
||||||
as SnCloudFile,packId: null == packId ? _self.packId : packId // ignore: cast_nullable_to_non_nullable
|
as SnCloudFile,packId: null == packId ? _self.packId : packId // ignore: cast_nullable_to_non_nullable
|
||||||
as String,pack: freezed == pack ? _self.pack : pack // ignore: cast_nullable_to_non_nullable
|
as String,pack: freezed == pack ? _self.pack : pack // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -179,10 +178,10 @@ return $default(_that);case _:
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String slug, String imageId, SnCloudFile image, String packId, SnStickerPack? pack, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt)? $default,{required TResult orElse(),}) {final _that = this;
|
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String slug, SnCloudFile image, String packId, SnStickerPack? pack, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt)? $default,{required TResult orElse(),}) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _SnSticker() when $default != null:
|
case _SnSticker() when $default != null:
|
||||||
return $default(_that.id,_that.slug,_that.imageId,_that.image,_that.packId,_that.pack,_that.createdAt,_that.updatedAt,_that.deletedAt);case _:
|
return $default(_that.id,_that.slug,_that.image,_that.packId,_that.pack,_that.createdAt,_that.updatedAt,_that.deletedAt);case _:
|
||||||
return orElse();
|
return orElse();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -200,10 +199,10 @@ return $default(_that.id,_that.slug,_that.imageId,_that.image,_that.packId,_that
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String slug, String imageId, SnCloudFile image, String packId, SnStickerPack? pack, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt) $default,) {final _that = this;
|
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String slug, SnCloudFile image, String packId, SnStickerPack? pack, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt) $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _SnSticker():
|
case _SnSticker():
|
||||||
return $default(_that.id,_that.slug,_that.imageId,_that.image,_that.packId,_that.pack,_that.createdAt,_that.updatedAt,_that.deletedAt);}
|
return $default(_that.id,_that.slug,_that.image,_that.packId,_that.pack,_that.createdAt,_that.updatedAt,_that.deletedAt);}
|
||||||
}
|
}
|
||||||
/// A variant of `when` that fallback to returning `null`
|
/// A variant of `when` that fallback to returning `null`
|
||||||
///
|
///
|
||||||
@@ -217,10 +216,10 @@ return $default(_that.id,_that.slug,_that.imageId,_that.image,_that.packId,_that
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String slug, String imageId, SnCloudFile image, String packId, SnStickerPack? pack, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt)? $default,) {final _that = this;
|
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String slug, SnCloudFile image, String packId, SnStickerPack? pack, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt)? $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _SnSticker() when $default != null:
|
case _SnSticker() when $default != null:
|
||||||
return $default(_that.id,_that.slug,_that.imageId,_that.image,_that.packId,_that.pack,_that.createdAt,_that.updatedAt,_that.deletedAt);case _:
|
return $default(_that.id,_that.slug,_that.image,_that.packId,_that.pack,_that.createdAt,_that.updatedAt,_that.deletedAt);case _:
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -232,12 +231,11 @@ return $default(_that.id,_that.slug,_that.imageId,_that.image,_that.packId,_that
|
|||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
|
|
||||||
class _SnSticker implements SnSticker {
|
class _SnSticker implements SnSticker {
|
||||||
const _SnSticker({required this.id, required this.slug, required this.imageId, required this.image, required this.packId, required this.pack, required this.createdAt, required this.updatedAt, required this.deletedAt});
|
const _SnSticker({required this.id, required this.slug, required this.image, required this.packId, required this.pack, required this.createdAt, required this.updatedAt, required this.deletedAt});
|
||||||
factory _SnSticker.fromJson(Map<String, dynamic> json) => _$SnStickerFromJson(json);
|
factory _SnSticker.fromJson(Map<String, dynamic> json) => _$SnStickerFromJson(json);
|
||||||
|
|
||||||
@override final String id;
|
@override final String id;
|
||||||
@override final String slug;
|
@override final String slug;
|
||||||
@override final String imageId;
|
|
||||||
@override final SnCloudFile image;
|
@override final SnCloudFile image;
|
||||||
@override final String packId;
|
@override final String packId;
|
||||||
@override final SnStickerPack? pack;
|
@override final SnStickerPack? pack;
|
||||||
@@ -258,16 +256,16 @@ Map<String, dynamic> toJson() {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnSticker&&(identical(other.id, id) || other.id == id)&&(identical(other.slug, slug) || other.slug == slug)&&(identical(other.imageId, imageId) || other.imageId == imageId)&&(identical(other.image, image) || other.image == image)&&(identical(other.packId, packId) || other.packId == packId)&&(identical(other.pack, pack) || other.pack == pack)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnSticker&&(identical(other.id, id) || other.id == id)&&(identical(other.slug, slug) || other.slug == slug)&&(identical(other.image, image) || other.image == image)&&(identical(other.packId, packId) || other.packId == packId)&&(identical(other.pack, pack) || other.pack == pack)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.deletedAt, deletedAt) || other.deletedAt == deletedAt));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType,id,slug,imageId,image,packId,pack,createdAt,updatedAt,deletedAt);
|
int get hashCode => Object.hash(runtimeType,id,slug,image,packId,pack,createdAt,updatedAt,deletedAt);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'SnSticker(id: $id, slug: $slug, imageId: $imageId, image: $image, packId: $packId, pack: $pack, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)';
|
return 'SnSticker(id: $id, slug: $slug, image: $image, packId: $packId, pack: $pack, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -278,7 +276,7 @@ abstract mixin class _$SnStickerCopyWith<$Res> implements $SnStickerCopyWith<$Re
|
|||||||
factory _$SnStickerCopyWith(_SnSticker value, $Res Function(_SnSticker) _then) = __$SnStickerCopyWithImpl;
|
factory _$SnStickerCopyWith(_SnSticker value, $Res Function(_SnSticker) _then) = __$SnStickerCopyWithImpl;
|
||||||
@override @useResult
|
@override @useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
String id, String slug, String imageId, SnCloudFile image, String packId, SnStickerPack? pack, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt
|
String id, String slug, SnCloudFile image, String packId, SnStickerPack? pack, DateTime createdAt, DateTime updatedAt, DateTime? deletedAt
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -295,11 +293,10 @@ class __$SnStickerCopyWithImpl<$Res>
|
|||||||
|
|
||||||
/// Create a copy of SnSticker
|
/// Create a copy of SnSticker
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? slug = null,Object? imageId = null,Object? image = null,Object? packId = null,Object? pack = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) {
|
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? slug = null,Object? image = null,Object? packId = null,Object? pack = freezed,Object? createdAt = null,Object? updatedAt = null,Object? deletedAt = freezed,}) {
|
||||||
return _then(_SnSticker(
|
return _then(_SnSticker(
|
||||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||||
as String,slug: null == slug ? _self.slug : slug // ignore: cast_nullable_to_non_nullable
|
as String,slug: null == slug ? _self.slug : slug // ignore: cast_nullable_to_non_nullable
|
||||||
as String,imageId: null == imageId ? _self.imageId : imageId // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,image: null == image ? _self.image : image // ignore: cast_nullable_to_non_nullable
|
as String,image: null == image ? _self.image : image // ignore: cast_nullable_to_non_nullable
|
||||||
as SnCloudFile,packId: null == packId ? _self.packId : packId // ignore: cast_nullable_to_non_nullable
|
as SnCloudFile,packId: null == packId ? _self.packId : packId // ignore: cast_nullable_to_non_nullable
|
||||||
as String,pack: freezed == pack ? _self.pack : pack // ignore: cast_nullable_to_non_nullable
|
as String,pack: freezed == pack ? _self.pack : pack // ignore: cast_nullable_to_non_nullable
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ part of 'sticker.dart';
|
|||||||
_SnSticker _$SnStickerFromJson(Map<String, dynamic> json) => _SnSticker(
|
_SnSticker _$SnStickerFromJson(Map<String, dynamic> json) => _SnSticker(
|
||||||
id: json['id'] as String,
|
id: json['id'] as String,
|
||||||
slug: json['slug'] as String,
|
slug: json['slug'] as String,
|
||||||
imageId: json['image_id'] as String,
|
|
||||||
image: SnCloudFile.fromJson(json['image'] as Map<String, dynamic>),
|
image: SnCloudFile.fromJson(json['image'] as Map<String, dynamic>),
|
||||||
packId: json['pack_id'] as String,
|
packId: json['pack_id'] as String,
|
||||||
pack:
|
pack:
|
||||||
@@ -28,7 +27,6 @@ Map<String, dynamic> _$SnStickerToJson(_SnSticker instance) =>
|
|||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
'id': instance.id,
|
'id': instance.id,
|
||||||
'slug': instance.slug,
|
'slug': instance.slug,
|
||||||
'image_id': instance.imageId,
|
|
||||||
'image': instance.image.toJson(),
|
'image': instance.image.toJson(),
|
||||||
'pack_id': instance.packId,
|
'pack_id': instance.packId,
|
||||||
'pack': instance.pack?.toJson(),
|
'pack': instance.pack?.toJson(),
|
||||||
|
|||||||
@@ -238,10 +238,17 @@ class ChatListBodyWidget extends HookConsumerWidget {
|
|||||||
room: item,
|
room: item,
|
||||||
isDirect: item.type == 1,
|
isDirect: item.type == 1,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.pushNamed(
|
if (isWideScreen(context)) {
|
||||||
'chatRoom',
|
context.replaceNamed(
|
||||||
pathParameters: {'id': item.id},
|
'chatRoom',
|
||||||
);
|
pathParameters: {'id': item.id},
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
context.pushNamed(
|
||||||
|
'chatRoom',
|
||||||
|
pathParameters: {'id': item.id},
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ class StickerPackDetailContent extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: CloudImageWidget(
|
child: CloudImageWidget(
|
||||||
fileId: sticker.imageId,
|
fileId: sticker.image.id,
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -318,7 +318,7 @@ class StickerForm extends HookConsumerWidget {
|
|||||||
|
|
||||||
final formKey = useMemoized(() => GlobalKey<FormState>(), []);
|
final formKey = useMemoized(() => GlobalKey<FormState>(), []);
|
||||||
|
|
||||||
final image = useState<String?>(id == null ? '' : sticker.value?.imageId);
|
final image = useState<String?>(id == null ? '' : sticker.value?.image.id);
|
||||||
final imageController = useTextEditingController(text: image.value);
|
final imageController = useTextEditingController(text: image.value);
|
||||||
final slugController = useTextEditingController(
|
final slugController = useTextEditingController(
|
||||||
text: id == null ? '' : sticker.value?.slug,
|
text: id == null ? '' : sticker.value?.slug,
|
||||||
@@ -326,8 +326,8 @@ class StickerForm extends HookConsumerWidget {
|
|||||||
|
|
||||||
useEffect(() {
|
useEffect(() {
|
||||||
if (sticker.value != null) {
|
if (sticker.value != null) {
|
||||||
image.value = sticker.value!.imageId;
|
image.value = sticker.value!.image.id;
|
||||||
imageController.text = sticker.value!.imageId;
|
imageController.text = sticker.value!.image.id;
|
||||||
slugController.text = sticker.value!.slug;
|
slugController.text = sticker.value!.slug;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ class MarketplaceStickerPackDetailScreen extends HookConsumerWidget {
|
|||||||
child: AspectRatio(
|
child: AspectRatio(
|
||||||
aspectRatio: 1,
|
aspectRatio: 1,
|
||||||
child: CloudImageWidget(
|
child: CloudImageWidget(
|
||||||
fileId: sticker.imageId,
|
fileId: sticker.image.id,
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -613,7 +613,7 @@ class ChatInput extends HookConsumerWidget {
|
|||||||
width: 28,
|
width: 28,
|
||||||
height: 28,
|
height: 28,
|
||||||
child: CloudImageWidget(
|
child: CloudImageWidget(
|
||||||
fileId: sticker.imageId,
|
fileId: sticker.image.id,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ class MarkdownTextContent extends HookConsumerWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final baseUrl = ref.watch(serverUrlProvider);
|
|
||||||
final doesEnlargeSticker = useMemoized(() {
|
final doesEnlargeSticker = useMemoized(() {
|
||||||
// Check if content only contains one sticker by matching the sticker pattern
|
// Check if content only contains one sticker by matching the sticker pattern
|
||||||
final stickerPattern = RegExp(stickerRegex);
|
final stickerPattern = RegExp(stickerRegex);
|
||||||
@@ -88,6 +87,14 @@ class MarkdownTextContent extends HookConsumerWidget {
|
|||||||
onToggle: () => spoilerRevealed.value = !spoilerRevealed.value,
|
onToggle: () => spoilerRevealed.value = !spoilerRevealed.value,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
final baseUrl = ref.watch(serverUrlProvider);
|
||||||
|
final stickerGenerator = StickerGenerator(
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||||
|
foregroundColor: Theme.of(context).colorScheme.onPrimary,
|
||||||
|
isEnlarged: doesEnlargeSticker,
|
||||||
|
baseUrl: baseUrl,
|
||||||
|
);
|
||||||
|
|
||||||
return MarkdownBlock(
|
return MarkdownBlock(
|
||||||
data: content,
|
data: content,
|
||||||
selectable: isSelectable,
|
selectable: isSelectable,
|
||||||
@@ -186,28 +193,6 @@ class MarkdownTextContent extends HookConsumerWidget {
|
|||||||
).clipRRect(all: 8),
|
).clipRRect(all: 8),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
case 'stickers':
|
|
||||||
final size = doesEnlargeSticker ? 96.0 : 24.0;
|
|
||||||
final stickerUri =
|
|
||||||
'$baseUrl/sphere/stickers/lookup/${uri.pathSegments[0]}/open';
|
|
||||||
return ClipRRect(
|
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Theme.of(context).colorScheme.surfaceContainer,
|
|
||||||
borderRadius: const BorderRadius.all(
|
|
||||||
Radius.circular(8),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: UniversalImage(
|
|
||||||
uri: stickerUri,
|
|
||||||
width: size,
|
|
||||||
height: size,
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
noCacheOptimization: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final content = ClipRRect(
|
final content = ClipRRect(
|
||||||
@@ -228,7 +213,12 @@ class MarkdownTextContent extends HookConsumerWidget {
|
|||||||
generator: MarkdownTextContent.buildGenerator(
|
generator: MarkdownTextContent.buildGenerator(
|
||||||
isDark: isDark,
|
isDark: isDark,
|
||||||
linesMargin: linesMargin,
|
linesMargin: linesMargin,
|
||||||
generators: [mentionGenerator, highlightGenerator, spoilerGenerator],
|
generators: [
|
||||||
|
mentionGenerator,
|
||||||
|
highlightGenerator,
|
||||||
|
spoilerGenerator,
|
||||||
|
stickerGenerator,
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -284,9 +274,8 @@ class _StickerInlineSyntax extends markdown.InlineSyntax {
|
|||||||
@override
|
@override
|
||||||
bool onMatch(markdown.InlineParser parser, Match match) {
|
bool onMatch(markdown.InlineParser parser, Match match) {
|
||||||
final placeholder = match[1]!;
|
final placeholder = match[1]!;
|
||||||
final image = markdown.Element.text('img', '')
|
final element = markdown.Element('sticker', [markdown.Text(placeholder)]);
|
||||||
..attributes['src'] = Uri.encodeFull('solian://stickers/$placeholder');
|
parser.addNode(element);
|
||||||
parser.addNode(image);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -559,3 +548,68 @@ class SpoilerSpanNode extends SpanNode {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class StickerGenerator extends SpanNodeGeneratorWithTag {
|
||||||
|
StickerGenerator({
|
||||||
|
required Color backgroundColor,
|
||||||
|
required Color foregroundColor,
|
||||||
|
required bool isEnlarged,
|
||||||
|
required String baseUrl,
|
||||||
|
}) : super(
|
||||||
|
tag: 'sticker',
|
||||||
|
generator: (
|
||||||
|
markdown.Element element,
|
||||||
|
MarkdownConfig config,
|
||||||
|
WidgetVisitor visitor,
|
||||||
|
) {
|
||||||
|
return StickerSpanNode(
|
||||||
|
placeholder: element.textContent,
|
||||||
|
backgroundColor: backgroundColor,
|
||||||
|
foregroundColor: foregroundColor,
|
||||||
|
isEnlarged: isEnlarged,
|
||||||
|
baseUrl: baseUrl,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
class StickerSpanNode extends SpanNode {
|
||||||
|
final String placeholder;
|
||||||
|
final Color backgroundColor;
|
||||||
|
final Color foregroundColor;
|
||||||
|
final bool isEnlarged;
|
||||||
|
final String baseUrl;
|
||||||
|
|
||||||
|
StickerSpanNode({
|
||||||
|
required this.placeholder,
|
||||||
|
required this.backgroundColor,
|
||||||
|
required this.foregroundColor,
|
||||||
|
required this.isEnlarged,
|
||||||
|
required this.baseUrl,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
InlineSpan build() {
|
||||||
|
final size = isEnlarged ? 96.0 : 24.0;
|
||||||
|
final stickerUri = '$baseUrl/sphere/stickers/lookup/$placeholder/open';
|
||||||
|
return WidgetSpan(
|
||||||
|
alignment: PlaceholderAlignment.middle,
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: backgroundColor.withOpacity(0.1),
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||||
|
),
|
||||||
|
child: UniversalImage(
|
||||||
|
uri: stickerUri,
|
||||||
|
width: size,
|
||||||
|
height: size,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
noCacheOptimization: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ class ComposeFormFields extends HookConsumerWidget {
|
|||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 28,
|
width: 28,
|
||||||
height: 28,
|
height: 28,
|
||||||
child: CloudImageWidget(fileId: sticker.imageId),
|
child: CloudImageWidget(fileId: sticker.image.id),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -580,7 +580,8 @@ class PostHeader extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Flexible(
|
Flexible(
|
||||||
child:
|
child:
|
||||||
item.publisher.account != null
|
(item.publisher.account != null &&
|
||||||
|
item.publisher.type == 0)
|
||||||
? AccountName(
|
? AccountName(
|
||||||
account: item.publisher.account!,
|
account: item.publisher.account!,
|
||||||
textOverride: item.publisher.nick,
|
textOverride: item.publisher.nick,
|
||||||
@@ -592,7 +593,10 @@ class PostHeader extends StatelessWidget {
|
|||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
).bold(),
|
).bold(),
|
||||||
),
|
),
|
||||||
if (item.publisher.verification != null)
|
if ((item.publisher.account?.profile.verification !=
|
||||||
|
null &&
|
||||||
|
item.publisher.type == 0) &&
|
||||||
|
item.publisher.verification != null)
|
||||||
VerificationMark(mark: item.publisher.verification!),
|
VerificationMark(mark: item.publisher.verification!),
|
||||||
if (item.realm == null)
|
if (item.realm == null)
|
||||||
Flexible(
|
Flexible(
|
||||||
@@ -752,15 +756,21 @@ class PostBody extends ConsumerWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
const Icon(Symbols.edit, size: 16),
|
const Icon(Symbols.edit, size: 16),
|
||||||
Text(
|
Tooltip(
|
||||||
'editedAt'.tr(
|
message:
|
||||||
args: [
|
|
||||||
!isFullPost && isRelativeTime
|
!isFullPost && isRelativeTime
|
||||||
? item.editedAt!.formatRelative(context)
|
? item.editedAt!.formatSystem()
|
||||||
: item.editedAt!.formatSystem(),
|
: item.editedAt!.formatRelative(context),
|
||||||
],
|
child: Text(
|
||||||
),
|
'editedAt'.tr(
|
||||||
).fontSize(13),
|
args: [
|
||||||
|
!isFullPost && isRelativeTime
|
||||||
|
? item.editedAt!.formatRelative(context)
|
||||||
|
: item.editedAt!.formatSystem(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
).fontSize(13),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ class _StickersGrid extends StatelessWidget {
|
|||||||
child: AspectRatio(
|
child: AspectRatio(
|
||||||
aspectRatio: 1,
|
aspectRatio: 1,
|
||||||
child: CloudImageWidget(
|
child: CloudImageWidget(
|
||||||
fileId: sticker.imageId,
|
fileId: sticker.image.id,
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user