✨ Quoted (repost) post
This commit is contained in:
parent
4884d04a51
commit
af044a86bc
@ -47,13 +47,11 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
|
|||||||
resp.data['body']['attachments']?.cast<String>() ?? [],
|
resp.data['body']['attachments']?.cast<String>() ?? [],
|
||||||
);
|
);
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
setState(() {
|
_data = SnPost.fromJson(resp.data).copyWith(
|
||||||
_data = SnPost.fromJson(resp.data).copyWith(
|
preload: SnPostPreload(
|
||||||
preload: SnPostPreload(
|
attachments: attachments,
|
||||||
attachments: attachments,
|
),
|
||||||
),
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
context.showErrorDialog(err);
|
context.showErrorDialog(err);
|
||||||
} finally {
|
} finally {
|
||||||
@ -87,13 +85,19 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
flexibleSpace: Column(
|
flexibleSpace: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(_data?.body['title'] ?? 'postNoun'.tr())
|
if (_data?.body['title'] != null)
|
||||||
.textStyle(Theme.of(context).textTheme.titleLarge!)
|
Text(_data?.body['title'] ?? 'postNoun'.tr())
|
||||||
.textColor(Colors.white),
|
.textStyle(Theme.of(context).textTheme.titleLarge!)
|
||||||
Text('postDetail')
|
.textColor(Colors.white),
|
||||||
.tr()
|
if (_data?.body['title'] != null)
|
||||||
.textColor(Colors.white.withAlpha((255 * 0.9).round())),
|
Text('postDetail'.tr())
|
||||||
|
.textColor(Colors.white.withAlpha((255 * 0.9).round()))
|
||||||
|
else
|
||||||
|
Text('postDetail'.tr())
|
||||||
|
.textStyle(Theme.of(context).textTheme.titleLarge!)
|
||||||
|
.textColor(Colors.white),
|
||||||
],
|
],
|
||||||
).padding(top: math.max(MediaQuery.of(context).padding.top, 8)),
|
).padding(top: math.max(MediaQuery.of(context).padding.top, 8)),
|
||||||
),
|
),
|
||||||
@ -104,7 +108,10 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
|
|||||||
),
|
),
|
||||||
if (_data != null)
|
if (_data != null)
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: PostItem(data: _data!, showComments: false),
|
child: PostItem(
|
||||||
|
data: _data!,
|
||||||
|
showComments: false,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SliverToBoxAdapter(child: Divider(height: 1)),
|
const SliverToBoxAdapter(child: Divider(height: 1)),
|
||||||
if (_data != null)
|
if (_data != null)
|
||||||
|
@ -20,13 +20,13 @@ class SnPost with _$SnPost {
|
|||||||
required String? aliasPrefix,
|
required String? aliasPrefix,
|
||||||
required List<dynamic> tags,
|
required List<dynamic> tags,
|
||||||
required List<dynamic> categories,
|
required List<dynamic> categories,
|
||||||
required dynamic replies,
|
required List<SnPost>? replies,
|
||||||
required dynamic replyId,
|
required int? replyId,
|
||||||
required dynamic repostId,
|
required int? repostId,
|
||||||
required dynamic replyTo,
|
required SnPost? replyTo,
|
||||||
required dynamic repostTo,
|
required SnPost? repostTo,
|
||||||
required dynamic visibleUsersList,
|
required List<int>? visibleUsersList,
|
||||||
required dynamic invisibleUsersList,
|
required List<int>? invisibleUsersList,
|
||||||
required int visibility,
|
required int visibility,
|
||||||
required DateTime? editedAt,
|
required DateTime? editedAt,
|
||||||
required DateTime? pinnedAt,
|
required DateTime? pinnedAt,
|
||||||
|
@ -31,13 +31,13 @@ mixin _$SnPost {
|
|||||||
String? get aliasPrefix => throw _privateConstructorUsedError;
|
String? get aliasPrefix => throw _privateConstructorUsedError;
|
||||||
List<dynamic> get tags => throw _privateConstructorUsedError;
|
List<dynamic> get tags => throw _privateConstructorUsedError;
|
||||||
List<dynamic> get categories => throw _privateConstructorUsedError;
|
List<dynamic> get categories => throw _privateConstructorUsedError;
|
||||||
dynamic get replies => throw _privateConstructorUsedError;
|
List<SnPost>? get replies => throw _privateConstructorUsedError;
|
||||||
dynamic get replyId => throw _privateConstructorUsedError;
|
int? get replyId => throw _privateConstructorUsedError;
|
||||||
dynamic get repostId => throw _privateConstructorUsedError;
|
int? get repostId => throw _privateConstructorUsedError;
|
||||||
dynamic get replyTo => throw _privateConstructorUsedError;
|
SnPost? get replyTo => throw _privateConstructorUsedError;
|
||||||
dynamic get repostTo => throw _privateConstructorUsedError;
|
SnPost? get repostTo => throw _privateConstructorUsedError;
|
||||||
dynamic get visibleUsersList => throw _privateConstructorUsedError;
|
List<int>? get visibleUsersList => throw _privateConstructorUsedError;
|
||||||
dynamic get invisibleUsersList => throw _privateConstructorUsedError;
|
List<int>? get invisibleUsersList => throw _privateConstructorUsedError;
|
||||||
int get visibility => throw _privateConstructorUsedError;
|
int get visibility => throw _privateConstructorUsedError;
|
||||||
DateTime? get editedAt => throw _privateConstructorUsedError;
|
DateTime? get editedAt => throw _privateConstructorUsedError;
|
||||||
DateTime? get pinnedAt => throw _privateConstructorUsedError;
|
DateTime? get pinnedAt => throw _privateConstructorUsedError;
|
||||||
@ -78,13 +78,13 @@ abstract class $SnPostCopyWith<$Res> {
|
|||||||
String? aliasPrefix,
|
String? aliasPrefix,
|
||||||
List<dynamic> tags,
|
List<dynamic> tags,
|
||||||
List<dynamic> categories,
|
List<dynamic> categories,
|
||||||
dynamic replies,
|
List<SnPost>? replies,
|
||||||
dynamic replyId,
|
int? replyId,
|
||||||
dynamic repostId,
|
int? repostId,
|
||||||
dynamic replyTo,
|
SnPost? replyTo,
|
||||||
dynamic repostTo,
|
SnPost? repostTo,
|
||||||
dynamic visibleUsersList,
|
List<int>? visibleUsersList,
|
||||||
dynamic invisibleUsersList,
|
List<int>? invisibleUsersList,
|
||||||
int visibility,
|
int visibility,
|
||||||
DateTime? editedAt,
|
DateTime? editedAt,
|
||||||
DateTime? pinnedAt,
|
DateTime? pinnedAt,
|
||||||
@ -99,6 +99,8 @@ abstract class $SnPostCopyWith<$Res> {
|
|||||||
SnMetric metric,
|
SnMetric metric,
|
||||||
SnPostPreload? preload});
|
SnPostPreload? preload});
|
||||||
|
|
||||||
|
$SnPostCopyWith<$Res>? get replyTo;
|
||||||
|
$SnPostCopyWith<$Res>? get repostTo;
|
||||||
$SnPublisherCopyWith<$Res> get publisher;
|
$SnPublisherCopyWith<$Res> get publisher;
|
||||||
$SnMetricCopyWith<$Res> get metric;
|
$SnMetricCopyWith<$Res> get metric;
|
||||||
$SnPostPreloadCopyWith<$Res>? get preload;
|
$SnPostPreloadCopyWith<$Res>? get preload;
|
||||||
@ -199,31 +201,31 @@ class _$SnPostCopyWithImpl<$Res, $Val extends SnPost>
|
|||||||
replies: freezed == replies
|
replies: freezed == replies
|
||||||
? _value.replies
|
? _value.replies
|
||||||
: replies // ignore: cast_nullable_to_non_nullable
|
: replies // ignore: cast_nullable_to_non_nullable
|
||||||
as dynamic,
|
as List<SnPost>?,
|
||||||
replyId: freezed == replyId
|
replyId: freezed == replyId
|
||||||
? _value.replyId
|
? _value.replyId
|
||||||
: replyId // ignore: cast_nullable_to_non_nullable
|
: replyId // ignore: cast_nullable_to_non_nullable
|
||||||
as dynamic,
|
as int?,
|
||||||
repostId: freezed == repostId
|
repostId: freezed == repostId
|
||||||
? _value.repostId
|
? _value.repostId
|
||||||
: repostId // ignore: cast_nullable_to_non_nullable
|
: repostId // ignore: cast_nullable_to_non_nullable
|
||||||
as dynamic,
|
as int?,
|
||||||
replyTo: freezed == replyTo
|
replyTo: freezed == replyTo
|
||||||
? _value.replyTo
|
? _value.replyTo
|
||||||
: replyTo // ignore: cast_nullable_to_non_nullable
|
: replyTo // ignore: cast_nullable_to_non_nullable
|
||||||
as dynamic,
|
as SnPost?,
|
||||||
repostTo: freezed == repostTo
|
repostTo: freezed == repostTo
|
||||||
? _value.repostTo
|
? _value.repostTo
|
||||||
: repostTo // ignore: cast_nullable_to_non_nullable
|
: repostTo // ignore: cast_nullable_to_non_nullable
|
||||||
as dynamic,
|
as SnPost?,
|
||||||
visibleUsersList: freezed == visibleUsersList
|
visibleUsersList: freezed == visibleUsersList
|
||||||
? _value.visibleUsersList
|
? _value.visibleUsersList
|
||||||
: visibleUsersList // ignore: cast_nullable_to_non_nullable
|
: visibleUsersList // ignore: cast_nullable_to_non_nullable
|
||||||
as dynamic,
|
as List<int>?,
|
||||||
invisibleUsersList: freezed == invisibleUsersList
|
invisibleUsersList: freezed == invisibleUsersList
|
||||||
? _value.invisibleUsersList
|
? _value.invisibleUsersList
|
||||||
: invisibleUsersList // ignore: cast_nullable_to_non_nullable
|
: invisibleUsersList // ignore: cast_nullable_to_non_nullable
|
||||||
as dynamic,
|
as List<int>?,
|
||||||
visibility: null == visibility
|
visibility: null == visibility
|
||||||
? _value.visibility
|
? _value.visibility
|
||||||
: visibility // ignore: cast_nullable_to_non_nullable
|
: visibility // ignore: cast_nullable_to_non_nullable
|
||||||
@ -279,6 +281,34 @@ class _$SnPostCopyWithImpl<$Res, $Val extends SnPost>
|
|||||||
) as $Val);
|
) as $Val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create a copy of SnPost
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
$SnPostCopyWith<$Res>? get replyTo {
|
||||||
|
if (_value.replyTo == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $SnPostCopyWith<$Res>(_value.replyTo!, (value) {
|
||||||
|
return _then(_value.copyWith(replyTo: value) as $Val);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a copy of SnPost
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
$SnPostCopyWith<$Res>? get repostTo {
|
||||||
|
if (_value.repostTo == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $SnPostCopyWith<$Res>(_value.repostTo!, (value) {
|
||||||
|
return _then(_value.copyWith(repostTo: value) as $Val);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// Create a copy of SnPost
|
/// Create a copy of SnPost
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@override
|
@override
|
||||||
@ -333,13 +363,13 @@ abstract class _$$SnPostImplCopyWith<$Res> implements $SnPostCopyWith<$Res> {
|
|||||||
String? aliasPrefix,
|
String? aliasPrefix,
|
||||||
List<dynamic> tags,
|
List<dynamic> tags,
|
||||||
List<dynamic> categories,
|
List<dynamic> categories,
|
||||||
dynamic replies,
|
List<SnPost>? replies,
|
||||||
dynamic replyId,
|
int? replyId,
|
||||||
dynamic repostId,
|
int? repostId,
|
||||||
dynamic replyTo,
|
SnPost? replyTo,
|
||||||
dynamic repostTo,
|
SnPost? repostTo,
|
||||||
dynamic visibleUsersList,
|
List<int>? visibleUsersList,
|
||||||
dynamic invisibleUsersList,
|
List<int>? invisibleUsersList,
|
||||||
int visibility,
|
int visibility,
|
||||||
DateTime? editedAt,
|
DateTime? editedAt,
|
||||||
DateTime? pinnedAt,
|
DateTime? pinnedAt,
|
||||||
@ -354,6 +384,10 @@ abstract class _$$SnPostImplCopyWith<$Res> implements $SnPostCopyWith<$Res> {
|
|||||||
SnMetric metric,
|
SnMetric metric,
|
||||||
SnPostPreload? preload});
|
SnPostPreload? preload});
|
||||||
|
|
||||||
|
@override
|
||||||
|
$SnPostCopyWith<$Res>? get replyTo;
|
||||||
|
@override
|
||||||
|
$SnPostCopyWith<$Res>? get repostTo;
|
||||||
@override
|
@override
|
||||||
$SnPublisherCopyWith<$Res> get publisher;
|
$SnPublisherCopyWith<$Res> get publisher;
|
||||||
@override
|
@override
|
||||||
@ -453,33 +487,33 @@ class __$$SnPostImplCopyWithImpl<$Res>
|
|||||||
: categories // ignore: cast_nullable_to_non_nullable
|
: categories // ignore: cast_nullable_to_non_nullable
|
||||||
as List<dynamic>,
|
as List<dynamic>,
|
||||||
replies: freezed == replies
|
replies: freezed == replies
|
||||||
? _value.replies
|
? _value._replies
|
||||||
: replies // ignore: cast_nullable_to_non_nullable
|
: replies // ignore: cast_nullable_to_non_nullable
|
||||||
as dynamic,
|
as List<SnPost>?,
|
||||||
replyId: freezed == replyId
|
replyId: freezed == replyId
|
||||||
? _value.replyId
|
? _value.replyId
|
||||||
: replyId // ignore: cast_nullable_to_non_nullable
|
: replyId // ignore: cast_nullable_to_non_nullable
|
||||||
as dynamic,
|
as int?,
|
||||||
repostId: freezed == repostId
|
repostId: freezed == repostId
|
||||||
? _value.repostId
|
? _value.repostId
|
||||||
: repostId // ignore: cast_nullable_to_non_nullable
|
: repostId // ignore: cast_nullable_to_non_nullable
|
||||||
as dynamic,
|
as int?,
|
||||||
replyTo: freezed == replyTo
|
replyTo: freezed == replyTo
|
||||||
? _value.replyTo
|
? _value.replyTo
|
||||||
: replyTo // ignore: cast_nullable_to_non_nullable
|
: replyTo // ignore: cast_nullable_to_non_nullable
|
||||||
as dynamic,
|
as SnPost?,
|
||||||
repostTo: freezed == repostTo
|
repostTo: freezed == repostTo
|
||||||
? _value.repostTo
|
? _value.repostTo
|
||||||
: repostTo // ignore: cast_nullable_to_non_nullable
|
: repostTo // ignore: cast_nullable_to_non_nullable
|
||||||
as dynamic,
|
as SnPost?,
|
||||||
visibleUsersList: freezed == visibleUsersList
|
visibleUsersList: freezed == visibleUsersList
|
||||||
? _value.visibleUsersList
|
? _value._visibleUsersList
|
||||||
: visibleUsersList // ignore: cast_nullable_to_non_nullable
|
: visibleUsersList // ignore: cast_nullable_to_non_nullable
|
||||||
as dynamic,
|
as List<int>?,
|
||||||
invisibleUsersList: freezed == invisibleUsersList
|
invisibleUsersList: freezed == invisibleUsersList
|
||||||
? _value.invisibleUsersList
|
? _value._invisibleUsersList
|
||||||
: invisibleUsersList // ignore: cast_nullable_to_non_nullable
|
: invisibleUsersList // ignore: cast_nullable_to_non_nullable
|
||||||
as dynamic,
|
as List<int>?,
|
||||||
visibility: null == visibility
|
visibility: null == visibility
|
||||||
? _value.visibility
|
? _value.visibility
|
||||||
: visibility // ignore: cast_nullable_to_non_nullable
|
: visibility // ignore: cast_nullable_to_non_nullable
|
||||||
@ -551,13 +585,13 @@ class _$SnPostImpl extends _SnPost {
|
|||||||
required this.aliasPrefix,
|
required this.aliasPrefix,
|
||||||
required final List<dynamic> tags,
|
required final List<dynamic> tags,
|
||||||
required final List<dynamic> categories,
|
required final List<dynamic> categories,
|
||||||
required this.replies,
|
required final List<SnPost>? replies,
|
||||||
required this.replyId,
|
required this.replyId,
|
||||||
required this.repostId,
|
required this.repostId,
|
||||||
required this.replyTo,
|
required this.replyTo,
|
||||||
required this.repostTo,
|
required this.repostTo,
|
||||||
required this.visibleUsersList,
|
required final List<int>? visibleUsersList,
|
||||||
required this.invisibleUsersList,
|
required final List<int>? invisibleUsersList,
|
||||||
required this.visibility,
|
required this.visibility,
|
||||||
required this.editedAt,
|
required this.editedAt,
|
||||||
required this.pinnedAt,
|
required this.pinnedAt,
|
||||||
@ -574,6 +608,9 @@ class _$SnPostImpl extends _SnPost {
|
|||||||
: _body = body,
|
: _body = body,
|
||||||
_tags = tags,
|
_tags = tags,
|
||||||
_categories = categories,
|
_categories = categories,
|
||||||
|
_replies = replies,
|
||||||
|
_visibleUsersList = visibleUsersList,
|
||||||
|
_invisibleUsersList = invisibleUsersList,
|
||||||
super._();
|
super._();
|
||||||
|
|
||||||
factory _$SnPostImpl.fromJson(Map<String, dynamic> json) =>
|
factory _$SnPostImpl.fromJson(Map<String, dynamic> json) =>
|
||||||
@ -619,20 +656,46 @@ class _$SnPostImpl extends _SnPost {
|
|||||||
return EqualUnmodifiableListView(_categories);
|
return EqualUnmodifiableListView(_categories);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final List<SnPost>? _replies;
|
||||||
@override
|
@override
|
||||||
final dynamic replies;
|
List<SnPost>? get replies {
|
||||||
|
final value = _replies;
|
||||||
|
if (value == null) return null;
|
||||||
|
if (_replies is EqualUnmodifiableListView) return _replies;
|
||||||
|
// ignore: implicit_dynamic_type
|
||||||
|
return EqualUnmodifiableListView(value);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final dynamic replyId;
|
final int? replyId;
|
||||||
@override
|
@override
|
||||||
final dynamic repostId;
|
final int? repostId;
|
||||||
@override
|
@override
|
||||||
final dynamic replyTo;
|
final SnPost? replyTo;
|
||||||
@override
|
@override
|
||||||
final dynamic repostTo;
|
final SnPost? repostTo;
|
||||||
|
final List<int>? _visibleUsersList;
|
||||||
@override
|
@override
|
||||||
final dynamic visibleUsersList;
|
List<int>? get visibleUsersList {
|
||||||
|
final value = _visibleUsersList;
|
||||||
|
if (value == null) return null;
|
||||||
|
if (_visibleUsersList is EqualUnmodifiableListView)
|
||||||
|
return _visibleUsersList;
|
||||||
|
// ignore: implicit_dynamic_type
|
||||||
|
return EqualUnmodifiableListView(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<int>? _invisibleUsersList;
|
||||||
@override
|
@override
|
||||||
final dynamic invisibleUsersList;
|
List<int>? get invisibleUsersList {
|
||||||
|
final value = _invisibleUsersList;
|
||||||
|
if (value == null) return null;
|
||||||
|
if (_invisibleUsersList is EqualUnmodifiableListView)
|
||||||
|
return _invisibleUsersList;
|
||||||
|
// ignore: implicit_dynamic_type
|
||||||
|
return EqualUnmodifiableListView(value);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final int visibility;
|
final int visibility;
|
||||||
@override
|
@override
|
||||||
@ -687,15 +750,17 @@ class _$SnPostImpl extends _SnPost {
|
|||||||
const DeepCollectionEquality().equals(other._tags, _tags) &&
|
const DeepCollectionEquality().equals(other._tags, _tags) &&
|
||||||
const DeepCollectionEquality()
|
const DeepCollectionEquality()
|
||||||
.equals(other._categories, _categories) &&
|
.equals(other._categories, _categories) &&
|
||||||
const DeepCollectionEquality().equals(other.replies, replies) &&
|
const DeepCollectionEquality().equals(other._replies, _replies) &&
|
||||||
const DeepCollectionEquality().equals(other.replyId, replyId) &&
|
(identical(other.replyId, replyId) || other.replyId == replyId) &&
|
||||||
const DeepCollectionEquality().equals(other.repostId, repostId) &&
|
(identical(other.repostId, repostId) ||
|
||||||
const DeepCollectionEquality().equals(other.replyTo, replyTo) &&
|
other.repostId == repostId) &&
|
||||||
const DeepCollectionEquality().equals(other.repostTo, repostTo) &&
|
(identical(other.replyTo, replyTo) || other.replyTo == replyTo) &&
|
||||||
|
(identical(other.repostTo, repostTo) ||
|
||||||
|
other.repostTo == repostTo) &&
|
||||||
const DeepCollectionEquality()
|
const DeepCollectionEquality()
|
||||||
.equals(other.visibleUsersList, visibleUsersList) &&
|
.equals(other._visibleUsersList, _visibleUsersList) &&
|
||||||
const DeepCollectionEquality()
|
const DeepCollectionEquality()
|
||||||
.equals(other.invisibleUsersList, invisibleUsersList) &&
|
.equals(other._invisibleUsersList, _invisibleUsersList) &&
|
||||||
(identical(other.visibility, visibility) ||
|
(identical(other.visibility, visibility) ||
|
||||||
other.visibility == visibility) &&
|
other.visibility == visibility) &&
|
||||||
(identical(other.editedAt, editedAt) ||
|
(identical(other.editedAt, editedAt) ||
|
||||||
@ -736,13 +801,13 @@ class _$SnPostImpl extends _SnPost {
|
|||||||
aliasPrefix,
|
aliasPrefix,
|
||||||
const DeepCollectionEquality().hash(_tags),
|
const DeepCollectionEquality().hash(_tags),
|
||||||
const DeepCollectionEquality().hash(_categories),
|
const DeepCollectionEquality().hash(_categories),
|
||||||
const DeepCollectionEquality().hash(replies),
|
const DeepCollectionEquality().hash(_replies),
|
||||||
const DeepCollectionEquality().hash(replyId),
|
replyId,
|
||||||
const DeepCollectionEquality().hash(repostId),
|
repostId,
|
||||||
const DeepCollectionEquality().hash(replyTo),
|
replyTo,
|
||||||
const DeepCollectionEquality().hash(repostTo),
|
repostTo,
|
||||||
const DeepCollectionEquality().hash(visibleUsersList),
|
const DeepCollectionEquality().hash(_visibleUsersList),
|
||||||
const DeepCollectionEquality().hash(invisibleUsersList),
|
const DeepCollectionEquality().hash(_invisibleUsersList),
|
||||||
visibility,
|
visibility,
|
||||||
editedAt,
|
editedAt,
|
||||||
pinnedAt,
|
pinnedAt,
|
||||||
@ -787,13 +852,13 @@ abstract class _SnPost extends SnPost {
|
|||||||
required final String? aliasPrefix,
|
required final String? aliasPrefix,
|
||||||
required final List<dynamic> tags,
|
required final List<dynamic> tags,
|
||||||
required final List<dynamic> categories,
|
required final List<dynamic> categories,
|
||||||
required final dynamic replies,
|
required final List<SnPost>? replies,
|
||||||
required final dynamic replyId,
|
required final int? replyId,
|
||||||
required final dynamic repostId,
|
required final int? repostId,
|
||||||
required final dynamic replyTo,
|
required final SnPost? replyTo,
|
||||||
required final dynamic repostTo,
|
required final SnPost? repostTo,
|
||||||
required final dynamic visibleUsersList,
|
required final List<int>? visibleUsersList,
|
||||||
required final dynamic invisibleUsersList,
|
required final List<int>? invisibleUsersList,
|
||||||
required final int visibility,
|
required final int visibility,
|
||||||
required final DateTime? editedAt,
|
required final DateTime? editedAt,
|
||||||
required final DateTime? pinnedAt,
|
required final DateTime? pinnedAt,
|
||||||
@ -834,19 +899,19 @@ abstract class _SnPost extends SnPost {
|
|||||||
@override
|
@override
|
||||||
List<dynamic> get categories;
|
List<dynamic> get categories;
|
||||||
@override
|
@override
|
||||||
dynamic get replies;
|
List<SnPost>? get replies;
|
||||||
@override
|
@override
|
||||||
dynamic get replyId;
|
int? get replyId;
|
||||||
@override
|
@override
|
||||||
dynamic get repostId;
|
int? get repostId;
|
||||||
@override
|
@override
|
||||||
dynamic get replyTo;
|
SnPost? get replyTo;
|
||||||
@override
|
@override
|
||||||
dynamic get repostTo;
|
SnPost? get repostTo;
|
||||||
@override
|
@override
|
||||||
dynamic get visibleUsersList;
|
List<int>? get visibleUsersList;
|
||||||
@override
|
@override
|
||||||
dynamic get invisibleUsersList;
|
List<int>? get invisibleUsersList;
|
||||||
@override
|
@override
|
||||||
int get visibility;
|
int get visibility;
|
||||||
@override
|
@override
|
||||||
|
@ -20,13 +20,23 @@ _$SnPostImpl _$$SnPostImplFromJson(Map<String, dynamic> json) => _$SnPostImpl(
|
|||||||
aliasPrefix: json['alias_prefix'] as String?,
|
aliasPrefix: json['alias_prefix'] as String?,
|
||||||
tags: json['tags'] as List<dynamic>,
|
tags: json['tags'] as List<dynamic>,
|
||||||
categories: json['categories'] as List<dynamic>,
|
categories: json['categories'] as List<dynamic>,
|
||||||
replies: json['replies'],
|
replies: (json['replies'] as List<dynamic>?)
|
||||||
replyId: json['reply_id'],
|
?.map((e) => SnPost.fromJson(e as Map<String, dynamic>))
|
||||||
repostId: json['repost_id'],
|
.toList(),
|
||||||
replyTo: json['reply_to'],
|
replyId: (json['reply_id'] as num?)?.toInt(),
|
||||||
repostTo: json['repost_to'],
|
repostId: (json['repost_id'] as num?)?.toInt(),
|
||||||
visibleUsersList: json['visible_users_list'],
|
replyTo: json['reply_to'] == null
|
||||||
invisibleUsersList: json['invisible_users_list'],
|
? null
|
||||||
|
: SnPost.fromJson(json['reply_to'] as Map<String, dynamic>),
|
||||||
|
repostTo: json['repost_to'] == null
|
||||||
|
? null
|
||||||
|
: SnPost.fromJson(json['repost_to'] as Map<String, dynamic>),
|
||||||
|
visibleUsersList: (json['visible_users_list'] as List<dynamic>?)
|
||||||
|
?.map((e) => (e as num).toInt())
|
||||||
|
.toList(),
|
||||||
|
invisibleUsersList: (json['invisible_users_list'] as List<dynamic>?)
|
||||||
|
?.map((e) => (e as num).toInt())
|
||||||
|
.toList(),
|
||||||
visibility: (json['visibility'] as num).toInt(),
|
visibility: (json['visibility'] as num).toInt(),
|
||||||
editedAt: json['edited_at'] == null
|
editedAt: json['edited_at'] == null
|
||||||
? null
|
? null
|
||||||
@ -68,11 +78,11 @@ Map<String, dynamic> _$$SnPostImplToJson(_$SnPostImpl instance) =>
|
|||||||
'alias_prefix': instance.aliasPrefix,
|
'alias_prefix': instance.aliasPrefix,
|
||||||
'tags': instance.tags,
|
'tags': instance.tags,
|
||||||
'categories': instance.categories,
|
'categories': instance.categories,
|
||||||
'replies': instance.replies,
|
'replies': instance.replies?.map((e) => e.toJson()).toList(),
|
||||||
'reply_id': instance.replyId,
|
'reply_id': instance.replyId,
|
||||||
'repost_id': instance.repostId,
|
'repost_id': instance.repostId,
|
||||||
'reply_to': instance.replyTo,
|
'reply_to': instance.replyTo?.toJson(),
|
||||||
'repost_to': instance.repostTo,
|
'repost_to': instance.repostTo?.toJson(),
|
||||||
'visible_users_list': instance.visibleUsersList,
|
'visible_users_list': instance.visibleUsersList,
|
||||||
'invisible_users_list': instance.invisibleUsersList,
|
'invisible_users_list': instance.invisibleUsersList,
|
||||||
'visibility': instance.visibility,
|
'visibility': instance.visibility,
|
||||||
|
@ -38,6 +38,11 @@ class PostItem extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
_PostContentHeader(data: data).padding(horizontal: 12, vertical: 8),
|
_PostContentHeader(data: data).padding(horizontal: 12, vertical: 8),
|
||||||
_PostContentBody(data: data.body).padding(horizontal: 16, bottom: 6),
|
_PostContentBody(data: data.body).padding(horizontal: 16, bottom: 6),
|
||||||
|
if (data.repostTo != null)
|
||||||
|
_PostQuoteContent(child: data.repostTo!).padding(
|
||||||
|
horizontal: 8,
|
||||||
|
bottom: 4,
|
||||||
|
),
|
||||||
if (data.preload?.attachments?.isNotEmpty ?? true)
|
if (data.preload?.attachments?.isNotEmpty ?? true)
|
||||||
AttachmentList(
|
AttachmentList(
|
||||||
data: data.preload!.attachments!,
|
data: data.preload!.attachments!,
|
||||||
@ -148,7 +153,13 @@ class _PostBottomAction extends StatelessWidget {
|
|||||||
|
|
||||||
class _PostContentHeader extends StatelessWidget {
|
class _PostContentHeader extends StatelessWidget {
|
||||||
final SnPost data;
|
final SnPost data;
|
||||||
const _PostContentHeader({required this.data});
|
final bool isCompact;
|
||||||
|
final bool showActions;
|
||||||
|
const _PostContentHeader({
|
||||||
|
required this.data,
|
||||||
|
this.isCompact = false,
|
||||||
|
this.showActions = true,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -157,13 +168,16 @@ class _PostContentHeader extends StatelessWidget {
|
|||||||
|
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
AccountImage(content: data.publisher.avatar),
|
AccountImage(
|
||||||
const Gap(12),
|
content: data.publisher.avatar,
|
||||||
Expanded(
|
radius: isCompact ? 12 : 20,
|
||||||
child: Column(
|
),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
Gap(isCompact ? 8 : 12),
|
||||||
|
if (isCompact)
|
||||||
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Text(data.publisher.nick).bold(),
|
Text(data.publisher.nick).bold(),
|
||||||
|
const Gap(4),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Text('@${data.publisher.name}').fontSize(13),
|
Text('@${data.publisher.name}').fontSize(13),
|
||||||
@ -174,86 +188,104 @@ class _PostContentHeader extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
).opacity(0.8),
|
).opacity(0.8),
|
||||||
],
|
],
|
||||||
|
)
|
||||||
|
else
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(data.publisher.nick).bold(),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Text('@${data.publisher.name}').fontSize(13),
|
||||||
|
const Gap(4),
|
||||||
|
Text(RelativeTime(context).format(
|
||||||
|
data.publishedAt ?? data.createdAt,
|
||||||
|
)).fontSize(13),
|
||||||
|
],
|
||||||
|
).opacity(0.8),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
if (showActions)
|
||||||
PopupMenuButton(
|
PopupMenuButton(
|
||||||
icon: const Icon(Symbols.more_horiz),
|
icon: const Icon(Symbols.more_horiz),
|
||||||
style: const ButtonStyle(
|
style: const ButtonStyle(
|
||||||
visualDensity: VisualDensity(horizontal: -4, vertical: -4),
|
visualDensity: VisualDensity(horizontal: -4, vertical: -4),
|
||||||
),
|
),
|
||||||
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
|
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
|
||||||
if (isAuthor)
|
if (isAuthor)
|
||||||
|
PopupMenuItem(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Symbols.edit),
|
||||||
|
const Gap(16),
|
||||||
|
Text('edit').tr(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
GoRouter.of(context).pushNamed(
|
||||||
|
'postEditor',
|
||||||
|
pathParameters: {'mode': data.typePlural},
|
||||||
|
queryParameters: {'editing': data.id.toString()},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (isAuthor)
|
||||||
|
PopupMenuItem(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Symbols.delete),
|
||||||
|
const Gap(16),
|
||||||
|
Text('delete').tr(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (isAuthor) const PopupMenuDivider(),
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
const Icon(Symbols.edit),
|
const Icon(Symbols.reply),
|
||||||
const Gap(16),
|
const Gap(16),
|
||||||
Text('edit').tr(),
|
Text('reply').tr(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
GoRouter.of(context).pushNamed(
|
GoRouter.of(context).pushNamed(
|
||||||
'postEditor',
|
'postEditor',
|
||||||
pathParameters: {'mode': data.typePlural},
|
pathParameters: {'mode': data.typePlural},
|
||||||
queryParameters: {'editing': data.id.toString()},
|
queryParameters: {'replying': data.id.toString()},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if (isAuthor)
|
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
const Icon(Symbols.delete),
|
const Icon(Symbols.forward),
|
||||||
const Gap(16),
|
const Gap(16),
|
||||||
Text('delete').tr(),
|
Text('repost').tr(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
GoRouter.of(context).pushNamed(
|
||||||
|
'postEditor',
|
||||||
|
pathParameters: {'mode': data.typePlural},
|
||||||
|
queryParameters: {'reposting': data.id.toString()},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const PopupMenuDivider(),
|
||||||
|
PopupMenuItem(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Symbols.flag),
|
||||||
|
const Gap(16),
|
||||||
|
Text('report').tr(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (isAuthor) const PopupMenuDivider(),
|
],
|
||||||
PopupMenuItem(
|
),
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
const Icon(Symbols.reply),
|
|
||||||
const Gap(16),
|
|
||||||
Text('reply').tr(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
GoRouter.of(context).pushNamed(
|
|
||||||
'postEditor',
|
|
||||||
pathParameters: {'mode': data.typePlural},
|
|
||||||
queryParameters: {'replying': data.id.toString()},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
PopupMenuItem(
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
const Icon(Symbols.forward),
|
|
||||||
const Gap(16),
|
|
||||||
Text('repost').tr(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
GoRouter.of(context).pushNamed(
|
|
||||||
'postEditor',
|
|
||||||
pathParameters: {'mode': data.typePlural},
|
|
||||||
queryParameters: {'reposting': data.id.toString()},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const PopupMenuDivider(),
|
|
||||||
PopupMenuItem(
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
const Icon(Symbols.flag),
|
|
||||||
const Gap(16),
|
|
||||||
Text('report').tr(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -269,3 +301,29 @@ class _PostContentBody extends StatelessWidget {
|
|||||||
return MarkdownTextContent(content: data['content']);
|
return MarkdownTextContent(content: data['content']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _PostQuoteContent extends StatelessWidget {
|
||||||
|
final SnPost child;
|
||||||
|
const _PostQuoteContent({super.key, required this.child});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||||
|
border: Border.all(
|
||||||
|
color: Theme.of(context).dividerColor,
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
_PostContentHeader(data: child, isCompact: true, showActions: false)
|
||||||
|
.padding(bottom: 4),
|
||||||
|
_PostContentBody(data: child.body),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user