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