shows posts now... (i know)
This commit is contained in:
parent
25895f4142
commit
bfa98720bf
|
@ -95,7 +95,6 @@ Future<http.Response> getTimelineFromServer() async {
|
|||
ids.add(json[i]["id"]);
|
||||
final post = PostModel.fromJson(json[i]);
|
||||
final thread = await post.getThread();
|
||||
print(thread.posts[0].content);
|
||||
i++;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ class LogoutButton extends StatelessWidget {
|
|||
FutureBuilder<String>(
|
||||
future: settings.loadInstanceUrl(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData && snapshot.data != null) {
|
||||
return Text("instance name");
|
||||
if (snapshot.hasData) {
|
||||
return Text(snapshot.data ?? "no-instance".i18n());
|
||||
} else {
|
||||
return const CircularProgressIndicator();
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:localization/localization.dart';
|
||||
import 'package:slothmu/partials/thread.dart';
|
||||
|
@ -29,12 +31,21 @@ class _TimelineState extends State<Timeline> {
|
|||
|
||||
Future fetchMore() async {
|
||||
loading = true;
|
||||
|
||||
final response = await tl.getTimelineFromServer();
|
||||
final json = jsonDecode(response.body)[0];
|
||||
final post = tl.PostModel.fromJson(json);
|
||||
final model = await post.getThread();
|
||||
|
||||
setState(() {
|
||||
if (children.isNotEmpty) {
|
||||
children.removeAt(children.length - 1);
|
||||
}
|
||||
children.addAll([Thread()]);
|
||||
children.addAll([
|
||||
Thread(
|
||||
model: model,
|
||||
)
|
||||
]);
|
||||
children.add(
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:localization/localization.dart';
|
||||
import '../business_logic/timeline/timeline.dart' as tl;
|
||||
|
||||
class Post extends StatefulWidget {
|
||||
const Post({Key? key}) : super(key: key);
|
||||
const Post({required this.model, Key? key}) : super(key: key);
|
||||
final tl.PostModel model;
|
||||
|
||||
@override
|
||||
State<Post> createState() => _PostState();
|
||||
|
@ -14,7 +16,9 @@ class _PostState extends State<Post> {
|
|||
return Column(
|
||||
children: [
|
||||
const DisplayName(),
|
||||
const PostBody(),
|
||||
PostBody(
|
||||
content: widget.model.content,
|
||||
),
|
||||
postActionBar(context),
|
||||
],
|
||||
);
|
||||
|
@ -54,7 +58,8 @@ class DisplayName extends StatelessWidget {
|
|||
}
|
||||
|
||||
class PostBody extends StatefulWidget {
|
||||
const PostBody({Key? key}) : super(key: key);
|
||||
const PostBody({required this.content, Key? key}) : super(key: key);
|
||||
final String content;
|
||||
|
||||
@override
|
||||
State<PostBody> createState() => _PostBodyState();
|
||||
|
@ -72,8 +77,7 @@ class _PostBodyState extends State<PostBody> {
|
|||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"sdkfjksdjfkd sldkjfksdjf dskfjsdkfjkds skdfjksdjfisdujfiosdhfjkldsfh sldkfjksdjfksdjfklsdjf"),
|
||||
Text(widget.content),
|
||||
OutlinedButton.icon(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
|
@ -95,8 +99,7 @@ class _PostBodyState extends State<PostBody> {
|
|||
textAlign: TextAlign.start,
|
||||
text: TextSpan(
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
text:
|
||||
"Lorem ipsumLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Auctor neque vitae tempus quam pellentesque. Scelerisque varius morbi enim nunc faucibus a. Tellus id interdum velit laoreet id donec ultrices. Aliquet bibendum enim facilisis gravida neque convallis a. Massa enim nec dui nunc mattis enim ut tellus. Sed felis eget velit aliquet sagittis id consectetur purus ut. Dignissim convallis aenean et tortor at risus. Integer vitae justo eget magna fermentum iaculis eu non. Ut placerat orci nulla pellentesque dignissim. Nisl suscipit adipiscing bibendum est ultricies. Mi ipsum faucibus vitae aliquet nec ullamcorper sit amet risus."),
|
||||
text: widget.content),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:slothmu/partials/post.dart';
|
||||
import '../business_logic/timeline/timeline.dart' as logic;
|
||||
|
||||
class Thread extends StatefulWidget {
|
||||
const Thread({Key? key}) : super(key: key);
|
||||
class Thread extends StatelessWidget {
|
||||
const Thread({required this.model, Key? key}) : super(key: key);
|
||||
final logic.ThreadModel model;
|
||||
|
||||
@override
|
||||
State<Thread> createState() => _ThreadState();
|
||||
}
|
||||
|
||||
class _ThreadState extends State<Thread> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Post> posts = [];
|
||||
for (int i = 0; i < model.posts.length; i++) {
|
||||
posts.add(Post(model: model.posts[i]));
|
||||
}
|
||||
|
||||
print(model.posts[0].content);
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
|
@ -27,7 +30,7 @@ class _ThreadState extends State<Thread> {
|
|||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
children: [Post(), Post(), Post()],
|
||||
children: posts,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
Loading…
Reference in New Issue