content width slider
This commit is contained in:
parent
af8967261e
commit
3d36b1936c
|
@ -67,6 +67,8 @@ class AccountSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Settings {
|
class Settings {
|
||||||
|
late double maxPostWidth = 0.8;
|
||||||
|
static const maxPostWidthKey = "max-post-width";
|
||||||
late Locale locale;
|
late Locale locale;
|
||||||
static const localeKey = "active-locale";
|
static const localeKey = "active-locale";
|
||||||
late int batchSize;
|
late int batchSize;
|
||||||
|
@ -103,9 +105,16 @@ class Settings {
|
||||||
settings.activeIdentity = settings.identities.keys.first;
|
settings.activeIdentity = settings.identities.keys.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
settings.maxPostWidth = settings.prefs.getDouble(maxPostWidthKey) ?? 0.8;
|
||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> saveMaxPostWidth(double width) {
|
||||||
|
maxPostWidth = width;
|
||||||
|
return prefs.setDouble(maxPostWidthKey, width);
|
||||||
|
}
|
||||||
|
|
||||||
Future<bool> addNewIdentity(String key) async {
|
Future<bool> addNewIdentity(String key) async {
|
||||||
List<String> a = identities.keys.toList();
|
List<String> a = identities.keys.toList();
|
||||||
a.removeWhere((element) {
|
a.removeWhere((element) {
|
||||||
|
|
|
@ -25,6 +25,9 @@
|
||||||
"app-settings": "app settings",
|
"app-settings": "app settings",
|
||||||
"local-timeline": "local",
|
"local-timeline": "local",
|
||||||
"home-timeline": "home",
|
"home-timeline": "home",
|
||||||
"public-timeline": "federated"
|
"public-timeline": "federated",
|
||||||
|
"content-width-label": "max content width",
|
||||||
|
"content-max-width-description": "determines how wide the timeline should be (required reloading the timeline)"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,8 @@ class AppSettings extends StatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
PostBatchSlider(
|
PostBatchSlider(
|
||||||
initialSize: global.settings!.batchSize,
|
initialSize: global.settings!.batchSize,
|
||||||
)
|
),
|
||||||
|
ContentWidthSlider(),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -65,3 +66,43 @@ class _PostBatchSliderState extends State<PostBatchSlider> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ContentWidthSlider extends StatefulWidget {
|
||||||
|
const ContentWidthSlider({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ContentWidthSlider> createState() => _ContentWidthSliderState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ContentWidthSliderState extends State<ContentWidthSlider> {
|
||||||
|
double value = global.settings!.maxPostWidth;
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
SelectableText(
|
||||||
|
"content-width-label".i18n(),
|
||||||
|
),
|
||||||
|
Slider(
|
||||||
|
min: 0.4,
|
||||||
|
max: 1.0,
|
||||||
|
label: "${(value * 100).round()}%",
|
||||||
|
value: value,
|
||||||
|
divisions: 6,
|
||||||
|
onChanged: ((double v) async {
|
||||||
|
setState(() {
|
||||||
|
value = v;
|
||||||
|
});
|
||||||
|
await global.settings!.saveMaxPostWidth(value);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SelectableText("content-max-width-description".i18n()),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -16,19 +16,17 @@ Widget settings(context) {
|
||||||
content: const about.AboutSettings(),
|
content: const about.AboutSettings(),
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
return Padding(
|
return ListView.separated(
|
||||||
padding: const EdgeInsets.all(24),
|
|
||||||
child: ListView.separated(
|
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return categories[index];
|
return categories[index];
|
||||||
},
|
},
|
||||||
separatorBuilder: (context, index) {
|
separatorBuilder: (context, index) {
|
||||||
return const Divider(
|
return const Divider(
|
||||||
|
height: 0,
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
itemCount: categories.length),
|
itemCount: categories.length);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class SettingsPanel extends StatelessWidget {
|
class SettingsPanel extends StatelessWidget {
|
||||||
|
@ -43,7 +41,9 @@ class SettingsPanel extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(24.0),
|
||||||
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.surface,
|
color: Theme.of(context).colorScheme.surface,
|
||||||
border: Border.all(color: Theme.of(context).colorScheme.secondary),
|
border: Border.all(color: Theme.of(context).colorScheme.secondary),
|
||||||
|
@ -60,6 +60,7 @@ class SettingsPanel extends StatelessWidget {
|
||||||
content,
|
content,
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,6 +114,7 @@ class _TimelineState extends State<Timeline>
|
||||||
onChanged: (dynamic value) {
|
onChanged: (dynamic value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedId = value ?? global.settings!.activeIdentity;
|
selectedId = value ?? global.settings!.activeIdentity;
|
||||||
|
global.settings!.saveActiveIdentity(selectedId);
|
||||||
reload();
|
reload();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:loris/partials/post.dart';
|
import 'package:loris/partials/post.dart';
|
||||||
import '../business_logic/timeline/timeline.dart' as logic;
|
import '../business_logic/timeline/timeline.dart' as logic;
|
||||||
|
import '../global.dart' as global;
|
||||||
|
|
||||||
class Thread extends StatelessWidget {
|
class Thread extends StatelessWidget {
|
||||||
const Thread({required this.model, Key? key}) : super(key: key);
|
const Thread({required this.model, Key? key}) : super(key: key);
|
||||||
|
@ -20,8 +21,10 @@ class Thread extends StatelessWidget {
|
||||||
padding: const EdgeInsets.all(4),
|
padding: const EdgeInsets.all(4),
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(24),
|
padding: const EdgeInsets.all(24),
|
||||||
width: MediaQuery.of(context).size.width / 1.2,
|
width: (MediaQuery.of(context).size.width *
|
||||||
constraints: const BoxConstraints(maxWidth: 1000, minWidth: 375),
|
global.settings!.maxPostWidth) -
|
||||||
|
56,
|
||||||
|
constraints: const BoxConstraints(minWidth: 375),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.surface,
|
color: Theme.of(context).colorScheme.surface,
|
||||||
border:
|
border:
|
||||||
|
|
Loading…
Reference in New Issue