finish threads! :)
This commit is contained in:
parent
631cabbf8d
commit
4b581400d5
|
@ -12,9 +12,15 @@ class FullPostView extends StatefulWidget {
|
||||||
super.key,
|
super.key,
|
||||||
required this.originPostModel,
|
required this.originPostModel,
|
||||||
this.identities,
|
this.identities,
|
||||||
|
this.hidden = true,
|
||||||
|
this.ancestors,
|
||||||
|
this.descendants,
|
||||||
});
|
});
|
||||||
final PostModel originPostModel;
|
final PostModel originPostModel;
|
||||||
final Map<String, PostModel>? identities;
|
final Map<String, PostModel>? identities;
|
||||||
|
final bool hidden;
|
||||||
|
final List<PostModel>? ancestors;
|
||||||
|
final List<PostModel>? descendants;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<FullPostView> createState() => _FullPostViewState();
|
State<FullPostView> createState() => _FullPostViewState();
|
||||||
|
@ -26,6 +32,7 @@ class _FullPostViewState extends State<FullPostView> {
|
||||||
Map<String, PostModel> identities = {};
|
Map<String, PostModel> identities = {};
|
||||||
String activeIdentity = "";
|
String activeIdentity = "";
|
||||||
int idsChecked = 1;
|
int idsChecked = 1;
|
||||||
|
bool sensitive = false;
|
||||||
|
|
||||||
void loadIdentities() async {
|
void loadIdentities() async {
|
||||||
global.settings!.identities.forEach((key, value) async {
|
global.settings!.identities.forEach((key, value) async {
|
||||||
|
@ -46,6 +53,7 @@ class _FullPostViewState extends State<FullPostView> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadPosts() async {
|
void loadPosts() async {
|
||||||
|
if (widget.ancestors == null || widget.descendants == null) {
|
||||||
final r = await getContextForPost(widget.originPostModel);
|
final r = await getContextForPost(widget.originPostModel);
|
||||||
if (r.value != null && mounted) {
|
if (r.value != null && mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
@ -53,10 +61,29 @@ class _FullPostViewState extends State<FullPostView> {
|
||||||
descendants = r.value!.descendants;
|
descendants = r.value!.descendants;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
for (var a in ancestors) {
|
||||||
|
if (a.sensitive) {
|
||||||
|
sensitive = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (var d in descendants) {
|
||||||
|
if (d.sensitive) {
|
||||||
|
sensitive = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
if (widget.ancestors != null) {
|
||||||
|
ancestors = widget.ancestors!;
|
||||||
|
}
|
||||||
|
if (widget.descendants != null) {
|
||||||
|
descendants = widget.descendants!;
|
||||||
|
}
|
||||||
|
|
||||||
|
sensitive = widget.originPostModel.sensitive;
|
||||||
if (widget.identities != null) {
|
if (widget.identities != null) {
|
||||||
idsChecked = global.settings!.identities.length;
|
idsChecked = global.settings!.identities.length;
|
||||||
}
|
}
|
||||||
|
@ -86,19 +113,26 @@ class _FullPostViewState extends State<FullPostView> {
|
||||||
children: [
|
children: [
|
||||||
global.settings!.identities.length > idsChecked
|
global.settings!.identities.length > idsChecked
|
||||||
? Column(
|
? Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
SelectableText(
|
SelectableText(
|
||||||
"${"post-found-on".i18n()} $idsChecked ${idsChecked == 1 ? "instance".i18n() : "instances".i18n()}"),
|
"${"post-found-on".i18n()} $idsChecked ${idsChecked == 1 ? "instance".i18n() : "instances".i18n()}"),
|
||||||
const LinearProgressIndicator(),
|
const LinearProgressIndicator(),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
: Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(8, 0, 8, 0),
|
||||||
|
child: Wrap(
|
||||||
|
alignment: WrapAlignment.spaceAround,
|
||||||
|
crossAxisAlignment: WrapCrossAlignment.center,
|
||||||
|
children: [
|
||||||
DropdownButtonHideUnderline(
|
DropdownButtonHideUnderline(
|
||||||
child: DropdownButton<String>(
|
child: DropdownButton<String>(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
value: activeIdentity,
|
value: activeIdentity,
|
||||||
style: Theme.of(context).textTheme.bodyMedium,
|
style: Theme.of(context).textTheme.bodyMedium,
|
||||||
iconEnabledColor: Theme.of(context).colorScheme.onSurface,
|
iconEnabledColor:
|
||||||
|
Theme.of(context).colorScheme.onSurface,
|
||||||
items: dropdownButtons,
|
items: dropdownButtons,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
@ -115,15 +149,41 @@ class _FullPostViewState extends State<FullPostView> {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (sensitive)
|
||||||
|
ElevatedButton.icon(
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => FullPostView(
|
||||||
|
originPostModel: widget.originPostModel,
|
||||||
|
hidden: !widget.hidden,
|
||||||
|
identities: identities,
|
||||||
|
ancestors: ancestors,
|
||||||
|
descendants: descendants,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
icon: Icon(widget.hidden
|
||||||
|
? Icons.visibility
|
||||||
|
: Icons.visibility_off),
|
||||||
|
label: Text(
|
||||||
|
widget.hidden ? "show".i18n() : "hide".i18n(),
|
||||||
|
))
|
||||||
]),
|
]),
|
||||||
|
),
|
||||||
Container(
|
Container(
|
||||||
height: MediaQuery.of(context).size.height * 2 / 3,
|
constraints: BoxConstraints(
|
||||||
constraints: global.getConstraints(context),
|
maxHeight: MediaQuery.of(context).size.height,
|
||||||
|
maxWidth: global.getConstraints(context).maxWidth),
|
||||||
width: global.getWidth(context),
|
width: global.getWidth(context),
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: SingleFullPostDisplay(
|
child: SingleFullPostDisplay(
|
||||||
ancestors: ancestors,
|
ancestors: ancestors,
|
||||||
descendants: descendants,
|
descendants: descendants,
|
||||||
|
hidden: widget.hidden,
|
||||||
level: 0,
|
level: 0,
|
||||||
model: identities[activeIdentity]!.reblog ??
|
model: identities[activeIdentity]!.reblog ??
|
||||||
identities[activeIdentity]!,
|
identities[activeIdentity]!,
|
||||||
|
@ -142,17 +202,19 @@ class SingleFullPostDisplay extends StatelessWidget {
|
||||||
required this.model,
|
required this.model,
|
||||||
required this.ancestors,
|
required this.ancestors,
|
||||||
required this.descendants,
|
required this.descendants,
|
||||||
|
this.hidden = true,
|
||||||
});
|
});
|
||||||
final int level;
|
final int level;
|
||||||
final PostModel model;
|
final PostModel model;
|
||||||
final List<PostModel> ancestors;
|
final List<PostModel> ancestors;
|
||||||
final List<PostModel> descendants;
|
final List<PostModel> descendants;
|
||||||
|
final bool hidden;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
List<Post> ancestorWidgets = ancestors
|
List<Post> ancestorWidgets = ancestors
|
||||||
.map(
|
.map(
|
||||||
(e) => Post(model: e),
|
(e) => Post(model: e, hideSensitive: hidden),
|
||||||
)
|
)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
|
@ -167,13 +229,17 @@ class SingleFullPostDisplay extends StatelessWidget {
|
||||||
model: element,
|
model: element,
|
||||||
ancestors: const [],
|
ancestors: const [],
|
||||||
descendants: descendants,
|
descendants: descendants,
|
||||||
|
hidden: hidden,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> c = [];
|
List<Widget> c = [];
|
||||||
c.addAll(ancestorWidgets);
|
c.addAll(ancestorWidgets);
|
||||||
c.add(Post(model: model));
|
c.add(Post(
|
||||||
|
model: model,
|
||||||
|
hideSensitive: hidden,
|
||||||
|
));
|
||||||
c.addAll(descendantsWidgets);
|
c.addAll(descendantsWidgets);
|
||||||
return Container(
|
return Container(
|
||||||
padding:
|
padding:
|
||||||
|
|
Loading…
Reference in New Issue