finish up for today
This commit is contained in:
parent
e80623ccbf
commit
5255bad5ab
|
@ -108,5 +108,5 @@ Future<bool> saveBatchSize(int size) async {
|
|||
|
||||
Future<int> loadBatchSize() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
return prefs.getInt("post-batch-size") ?? 5;
|
||||
return prefs.getInt("post-batch-size") ?? 20;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
enum MediaAttachmentType {
|
||||
image,
|
||||
video,
|
||||
gifv,
|
||||
audio,
|
||||
unknown,
|
||||
}
|
||||
|
||||
class MediaAttachmentModel {
|
||||
late MediaAttachmentType type;
|
||||
late String type;
|
||||
late String url;
|
||||
late String previewUrl;
|
||||
late String? description;
|
||||
|
@ -15,9 +7,7 @@ class MediaAttachmentModel {
|
|||
MediaAttachmentModel.fromJson(Map<String, dynamic> json) {
|
||||
url = json["url"];
|
||||
previewUrl = json["preview_url"];
|
||||
type = MediaAttachmentType.values.firstWhere((element) =>
|
||||
// ignore: prefer_interpolation_to_compose_strings
|
||||
element.toString() == "MediaAttachmentType." + json["type"]);
|
||||
type = json["type"];
|
||||
description = json["description"];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ class ThreadModel {
|
|||
}
|
||||
|
||||
Future<List<ThreadModel>> getTimelineFromServer(String? index) async {
|
||||
const limit = 5;
|
||||
final limit = await settings.loadBatchSize();
|
||||
final token = await settings.loadToken();
|
||||
|
||||
Map<String, String> query = {"limit": limit.toString()};
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
"logout": "log out",
|
||||
"show-in-browser": "show in browser",
|
||||
"post-options": "post options",
|
||||
"reblogged-by": "reblogged by:"
|
||||
"reblogged-by": "reblogged by:",
|
||||
"post-batch-size": "post batch size",
|
||||
"post-batch-size-description": "how many posts to load at a time\nfor slower internet or if you're not sure what to do use a low value (the default in most places is 20)"
|
||||
}
|
||||
|
|
@ -9,17 +9,60 @@ class AppSettings extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text("post-batch-size".i18n()),
|
||||
Slider(
|
||||
value: 3,
|
||||
min: 3,
|
||||
max: 100,
|
||||
onChanged: ((value) {}),
|
||||
)
|
||||
],
|
||||
)
|
||||
FutureBuilder<int>(
|
||||
future: settings.loadBatchSize(),
|
||||
builder: ((context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return PostBatchSlider(initialSize: snapshot.data ?? 5);
|
||||
}
|
||||
return const CircularProgressIndicator.adaptive();
|
||||
})),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class PostBatchSlider extends StatefulWidget {
|
||||
const PostBatchSlider({required this.initialSize, Key? key})
|
||||
: super(key: key);
|
||||
final int initialSize;
|
||||
@override
|
||||
State<PostBatchSlider> createState() => _PostBatchSliderState();
|
||||
}
|
||||
|
||||
class _PostBatchSliderState extends State<PostBatchSlider> {
|
||||
late int size;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
size = widget.initialSize;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text("post-batch-size".i18n()),
|
||||
Slider(
|
||||
label: size.toString(),
|
||||
value: size.toDouble(),
|
||||
divisions: 19,
|
||||
min: 5,
|
||||
max: 100,
|
||||
onChanged: ((value) {
|
||||
settings.saveBatchSize(value.toInt());
|
||||
setState(() {
|
||||
size = value.toInt();
|
||||
});
|
||||
}),
|
||||
)
|
||||
],
|
||||
),
|
||||
SelectableText("post-batch-size-description".i18n()),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -47,8 +47,9 @@ class _TimelineState extends State<Timeline>
|
|||
threads.add(Thread(model: models[i]));
|
||||
}
|
||||
|
||||
oldestId = models.last.posts.last.id;
|
||||
|
||||
if (models.isNotEmpty) {
|
||||
oldestId = models.last.posts.last.id;
|
||||
}
|
||||
children.addAll(threads);
|
||||
children.add(
|
||||
Row(
|
||||
|
|
|
@ -9,7 +9,7 @@ class MediaAttachments extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
List<Widget> children = [];
|
||||
for (int i = 0; i < models.length; i++) {
|
||||
if (models[i].type == MediaAttachmentType.image) {
|
||||
if (models[i].type == "image" || models[i].type == "gif") {
|
||||
children.add(ImageAttachmentDisplay(model: models[i]));
|
||||
} else {
|
||||
children.add(Text("media-not-supported".i18n()));
|
||||
|
@ -32,6 +32,7 @@ class ImageAttachmentDisplay extends StatelessWidget {
|
|||
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Image.network(
|
||||
model.url,
|
||||
errorBuilder: ((context, error, stackTrace) => const Icon(Icons.error)),
|
||||
width: double.infinity,
|
||||
fit: BoxFit.fitWidth,
|
||||
),
|
||||
|
|
|
@ -110,6 +110,10 @@ class ProfilePic extends StatelessWidget {
|
|||
if (url.isNotEmpty) {
|
||||
return Image.network(
|
||||
url,
|
||||
errorBuilder: (context, error, stackTrace) => const Icon(
|
||||
Icons.cruelty_free,
|
||||
size: width,
|
||||
),
|
||||
height: width,
|
||||
width: width,
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue