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 {
|
Future<int> loadBatchSize() async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
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 {
|
class MediaAttachmentModel {
|
||||||
late MediaAttachmentType type;
|
late String type;
|
||||||
late String url;
|
late String url;
|
||||||
late String previewUrl;
|
late String previewUrl;
|
||||||
late String? description;
|
late String? description;
|
||||||
|
@ -15,9 +7,7 @@ class MediaAttachmentModel {
|
||||||
MediaAttachmentModel.fromJson(Map<String, dynamic> json) {
|
MediaAttachmentModel.fromJson(Map<String, dynamic> json) {
|
||||||
url = json["url"];
|
url = json["url"];
|
||||||
previewUrl = json["preview_url"];
|
previewUrl = json["preview_url"];
|
||||||
type = MediaAttachmentType.values.firstWhere((element) =>
|
type = json["type"];
|
||||||
// ignore: prefer_interpolation_to_compose_strings
|
|
||||||
element.toString() == "MediaAttachmentType." + json["type"]);
|
|
||||||
description = json["description"];
|
description = json["description"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ class ThreadModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<ThreadModel>> getTimelineFromServer(String? index) async {
|
Future<List<ThreadModel>> getTimelineFromServer(String? index) async {
|
||||||
const limit = 5;
|
final limit = await settings.loadBatchSize();
|
||||||
final token = await settings.loadToken();
|
final token = await settings.loadToken();
|
||||||
|
|
||||||
Map<String, String> query = {"limit": limit.toString()};
|
Map<String, String> query = {"limit": limit.toString()};
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
"logout": "log out",
|
"logout": "log out",
|
||||||
"show-in-browser": "show in browser",
|
"show-in-browser": "show in browser",
|
||||||
"post-options": "post options",
|
"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) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
Row(
|
FutureBuilder<int>(
|
||||||
children: [
|
future: settings.loadBatchSize(),
|
||||||
Text("post-batch-size".i18n()),
|
builder: ((context, snapshot) {
|
||||||
Slider(
|
if (snapshot.hasData) {
|
||||||
value: 3,
|
return PostBatchSlider(initialSize: snapshot.data ?? 5);
|
||||||
min: 3,
|
}
|
||||||
max: 100,
|
return const CircularProgressIndicator.adaptive();
|
||||||
onChanged: ((value) {}),
|
})),
|
||||||
)
|
],
|
||||||
],
|
);
|
||||||
)
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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]));
|
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.addAll(threads);
|
||||||
children.add(
|
children.add(
|
||||||
Row(
|
Row(
|
||||||
|
|
|
@ -9,7 +9,7 @@ class MediaAttachments extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
List<Widget> children = [];
|
List<Widget> children = [];
|
||||||
for (int i = 0; i < models.length; i++) {
|
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]));
|
children.add(ImageAttachmentDisplay(model: models[i]));
|
||||||
} else {
|
} else {
|
||||||
children.add(Text("media-not-supported".i18n()));
|
children.add(Text("media-not-supported".i18n()));
|
||||||
|
@ -32,6 +32,7 @@ class ImageAttachmentDisplay extends StatelessWidget {
|
||||||
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||||
Image.network(
|
Image.network(
|
||||||
model.url,
|
model.url,
|
||||||
|
errorBuilder: ((context, error, stackTrace) => const Icon(Icons.error)),
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
fit: BoxFit.fitWidth,
|
fit: BoxFit.fitWidth,
|
||||||
),
|
),
|
||||||
|
|
|
@ -110,6 +110,10 @@ class ProfilePic extends StatelessWidget {
|
||||||
if (url.isNotEmpty) {
|
if (url.isNotEmpty) {
|
||||||
return Image.network(
|
return Image.network(
|
||||||
url,
|
url,
|
||||||
|
errorBuilder: (context, error, stackTrace) => const Icon(
|
||||||
|
Icons.cruelty_free,
|
||||||
|
size: width,
|
||||||
|
),
|
||||||
height: width,
|
height: width,
|
||||||
width: width,
|
width: width,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue