✨ Show post visibility
This commit is contained in:
parent
1809f2557d
commit
c21ca5573c
@ -24,6 +24,7 @@ class Post {
|
|||||||
String? alias;
|
String? alias;
|
||||||
String? areaAlias;
|
String? areaAlias;
|
||||||
dynamic body;
|
dynamic body;
|
||||||
|
int visibility;
|
||||||
List<Tag>? tags;
|
List<Tag>? tags;
|
||||||
List<Category>? categories;
|
List<Category>? categories;
|
||||||
List<Post>? replies;
|
List<Post>? replies;
|
||||||
@ -55,6 +56,7 @@ class Post {
|
|||||||
required this.areaAlias,
|
required this.areaAlias,
|
||||||
required this.type,
|
required this.type,
|
||||||
required this.body,
|
required this.body,
|
||||||
|
required this.visibility,
|
||||||
required this.tags,
|
required this.tags,
|
||||||
required this.categories,
|
required this.categories,
|
||||||
required this.replies,
|
required this.replies,
|
||||||
|
@ -20,6 +20,7 @@ Post _$PostFromJson(Map<String, dynamic> json) => Post(
|
|||||||
areaAlias: json['area_alias'] as String?,
|
areaAlias: json['area_alias'] as String?,
|
||||||
type: json['type'] as String,
|
type: json['type'] as String,
|
||||||
body: json['body'],
|
body: json['body'],
|
||||||
|
visibility: (json['visibility'] as num).toInt(),
|
||||||
tags: (json['tags'] as List<dynamic>?)
|
tags: (json['tags'] as List<dynamic>?)
|
||||||
?.map((e) => Tag.fromJson(e as Map<String, dynamic>))
|
?.map((e) => Tag.fromJson(e as Map<String, dynamic>))
|
||||||
.toList(),
|
.toList(),
|
||||||
@ -67,6 +68,7 @@ Map<String, dynamic> _$PostToJson(Post instance) => <String, dynamic>{
|
|||||||
'alias': instance.alias,
|
'alias': instance.alias,
|
||||||
'area_alias': instance.areaAlias,
|
'area_alias': instance.areaAlias,
|
||||||
'body': instance.body,
|
'body': instance.body,
|
||||||
|
'visibility': instance.visibility,
|
||||||
'tags': instance.tags?.map((e) => e.toJson()).toList(),
|
'tags': instance.tags?.map((e) => e.toJson()).toList(),
|
||||||
'categories': instance.categories?.map((e) => e.toJson()).toList(),
|
'categories': instance.categories?.map((e) => e.toJson()).toList(),
|
||||||
'replies': instance.replies?.map((e) => e.toJson()).toList(),
|
'replies': instance.replies?.map((e) => e.toJson()).toList(),
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import 'package:animations/animations.dart';
|
import 'package:animations/animations.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:flutter_animate/flutter_animate.dart';
|
import 'package:flutter_animate/flutter_animate.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:gap/gap.dart';
|
import 'package:gap/gap.dart';
|
||||||
@ -66,6 +65,14 @@ class _PostItemState extends State<PostItem> {
|
|||||||
Color get _unFocusColor =>
|
Color get _unFocusColor =>
|
||||||
Theme.of(context).colorScheme.onSurface.withOpacity(0.75);
|
Theme.of(context).colorScheme.onSurface.withOpacity(0.75);
|
||||||
|
|
||||||
|
static final visibilityIcons = [
|
||||||
|
Icons.public,
|
||||||
|
Icons.group,
|
||||||
|
Icons.visibility,
|
||||||
|
Icons.visibility_off,
|
||||||
|
Icons.lock,
|
||||||
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
item = widget.item;
|
item = widget.item;
|
||||||
@ -612,7 +619,24 @@ class _PostHeaderWidget extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (!isCompact)
|
if (!isCompact)
|
||||||
RelativeDate(item.publishedAt?.toLocal() ?? DateTime.now()),
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
RelativeDate(
|
||||||
|
item.publishedAt?.toLocal() ?? DateTime.now(),
|
||||||
|
isFull: isFullDate,
|
||||||
|
),
|
||||||
|
const Gap(4),
|
||||||
|
Icon(
|
||||||
|
_PostItemState.visibilityIcons[item.visibility],
|
||||||
|
size: 16,
|
||||||
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onSurface
|
||||||
|
.withOpacity(0.75),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user