From 30de8189bc021971302c7248f02cba9bc1e82ea1 Mon Sep 17 00:00:00 2001 From: zoe Date: Mon, 4 Jul 2022 19:37:53 +0200 Subject: [PATCH] rename to loris --- lib/business_logic/timeline/timeline.dart | 6 ++ lib/dialogues/makepost.dart | 6 +- lib/global.dart | 2 +- lib/i18n/de.json | 4 +- lib/i18n/en.json | 4 +- lib/pages/timeline/timeline.dart | 81 +++++++++++++++++++++-- lib/partials/main_scaffold.dart | 2 +- lib/partials/post.dart | 18 ++++- 8 files changed, 104 insertions(+), 19 deletions(-) diff --git a/lib/business_logic/timeline/timeline.dart b/lib/business_logic/timeline/timeline.dart index 8b13789..a5370fe 100644 --- a/lib/business_logic/timeline/timeline.dart +++ b/lib/business_logic/timeline/timeline.dart @@ -1 +1,7 @@ +import 'package:http/http.dart' as http; +class Thread {} + +class Post {} + +class Timeline {} diff --git a/lib/dialogues/makepost.dart b/lib/dialogues/makepost.dart index f811886..d4e7aea 100644 --- a/lib/dialogues/makepost.dart +++ b/lib/dialogues/makepost.dart @@ -34,11 +34,7 @@ class MakePostActionBar extends StatelessWidget { onPressed: () { Navigator.of(context).pop(); }, - icon: Icon(Icons.cancel), - ), - IconButton( - onPressed: null, - icon: Icon(Icons.save), + icon: const Icon(Icons.cancel), ), ], ); diff --git a/lib/global.dart b/lib/global.dart index 27cef8f..6abfd5c 100644 --- a/lib/global.dart +++ b/lib/global.dart @@ -1,6 +1,6 @@ import 'package:flutter/painting.dart'; -const String name = "slothmu"; +const String name = "loris"; const String version = "v0.1 'not even alpha'"; const String useragent = "$name/$version"; const String website = "https://git.kittycat.homes/zoe/slothmu"; diff --git a/lib/i18n/de.json b/lib/i18n/de.json index 01145a9..1197da5 100644 --- a/lib/i18n/de.json +++ b/lib/i18n/de.json @@ -9,6 +9,8 @@ "timeline" : "timeline", "chat": "chat", "notifications": "benachrichtigungen", - "settings": "einstellungen" + "settings": "einstellungen", + "show": "zeigen", + "hide": "verstecken" } \ No newline at end of file diff --git a/lib/i18n/en.json b/lib/i18n/en.json index 73e68cf..d23c3b8 100644 --- a/lib/i18n/en.json +++ b/lib/i18n/en.json @@ -9,6 +9,8 @@ "timeline" : "timeline", "chat": "chat", "notifications": "notifications", - "settings": "settings" + "settings": "settings", + "show": "show", + "hide": "hide" } \ No newline at end of file diff --git a/lib/pages/timeline/timeline.dart b/lib/pages/timeline/timeline.dart index 7403167..07fa28d 100644 --- a/lib/pages/timeline/timeline.dart +++ b/lib/pages/timeline/timeline.dart @@ -1,13 +1,80 @@ import 'package:flutter/material.dart'; -import 'package:slothmu/partials/post.dart'; +import 'package:localization/localization.dart'; +import '../../business_logic/settings.dart' as settings; import 'package:slothmu/partials/thread.dart'; -Widget timeline(context) { - return Container( - child: ListView( +class Timeline extends StatefulWidget { + const Timeline({Key? key}) : super(key: key); + + @override + State createState() => _TimelineState(); +} + +class _TimelineState extends State { + final controller = ScrollController(); + List children = []; + bool loading = false; + + @override + void initState() { + super.initState(); + fetchMore(); + controller.addListener(() { + if (controller.position.maxScrollExtent <= controller.offset && + !loading) { + fetchMore(); + } + }); + } + + Future fetchMore() async { + loading = true; + final token = await settings.loadAuthCode(); + setState(() { + if (children.isNotEmpty) { + children.removeAt(children.length - 1); + } + children.addAll([Thread()]); + children.add( + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextButton.icon( + onPressed: () { + fetchMore(); + }, + icon: const Icon(Icons.more_horiz), + label: Text("load-more".i18n()), + ) + ], + ), + ); + loading = false; + }); + } + + @override + void dispose() { + controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return ListView.separated( + physics: const AlwaysScrollableScrollPhysics(), + controller: controller, + itemBuilder: (context, index) { + return children[index]; + }, + separatorBuilder: (context, index) { + return const Divider( + color: Colors.transparent, + ); + }, + itemCount: children.length, padding: const EdgeInsets.fromLTRB(24, 0, 24, 64), addAutomaticKeepAlives: false, - children: [Thread(), Thread(), Thread()], - ), - ); + ); + } } diff --git a/lib/partials/main_scaffold.dart b/lib/partials/main_scaffold.dart index d895a5c..e7be562 100644 --- a/lib/partials/main_scaffold.dart +++ b/lib/partials/main_scaffold.dart @@ -19,7 +19,7 @@ class _MainScaffoldState extends State { @override Widget build(BuildContext context) { final screens = [ - timeline(context), + const Timeline(), chat(context), notifications(context), settings(context), diff --git a/lib/partials/post.dart b/lib/partials/post.dart index 9531ae1..deb24b6 100644 --- a/lib/partials/post.dart +++ b/lib/partials/post.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:localization/localization.dart'; class Post extends StatefulWidget { const Post({Key? key}) : super(key: key); @@ -61,6 +62,8 @@ class PostBody extends StatefulWidget { class _PostBodyState extends State { bool visible = false; + String cwButtonText = "show".i18n(); + Icon cwButtonIcon = const Icon(Icons.visibility); @override Widget build(BuildContext context) { return Container( @@ -69,14 +72,23 @@ class _PostBodyState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - TextButton.icon( + Text( + "sdkfjksdjfkd sldkjfksdjf dskfjsdkfjkds skdfjksdjfisdujfiosdhfjkldsfh sldkfjksdjfksdjfklsdjf"), + OutlinedButton.icon( onPressed: () { setState(() { visible = !visible; + if (visible) { + cwButtonIcon = const Icon(Icons.visibility_off); + cwButtonText = "hide".i18n(); + } else { + cwButtonText = "show".i18n(); + cwButtonIcon = const Icon(Icons.visibility); + } }); }, - icon: const Icon(Icons.warning), - label: const Text("warning")), + icon: cwButtonIcon, + label: Text(cwButtonText)), Visibility( visible: visible, child: RichText(