content width slider
This commit is contained in:
parent
af8967261e
commit
3d36b1936c
|
@ -67,6 +67,8 @@ class AccountSettings {
|
|||
}
|
||||
|
||||
class Settings {
|
||||
late double maxPostWidth = 0.8;
|
||||
static const maxPostWidthKey = "max-post-width";
|
||||
late Locale locale;
|
||||
static const localeKey = "active-locale";
|
||||
late int batchSize;
|
||||
|
@ -103,9 +105,16 @@ class Settings {
|
|||
settings.activeIdentity = settings.identities.keys.first;
|
||||
}
|
||||
|
||||
settings.maxPostWidth = settings.prefs.getDouble(maxPostWidthKey) ?? 0.8;
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
Future<bool> saveMaxPostWidth(double width) {
|
||||
maxPostWidth = width;
|
||||
return prefs.setDouble(maxPostWidthKey, width);
|
||||
}
|
||||
|
||||
Future<bool> addNewIdentity(String key) async {
|
||||
List<String> a = identities.keys.toList();
|
||||
a.removeWhere((element) {
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
"app-settings": "app settings",
|
||||
"local-timeline": "local",
|
||||
"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: [
|
||||
PostBatchSlider(
|
||||
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(),
|
||||
)
|
||||
];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: ListView.separated(
|
||||
itemBuilder: (context, index) {
|
||||
return categories[index];
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return const Divider(
|
||||
color: Colors.transparent,
|
||||
);
|
||||
},
|
||||
itemCount: categories.length),
|
||||
);
|
||||
return ListView.separated(
|
||||
itemBuilder: (context, index) {
|
||||
return categories[index];
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return const Divider(
|
||||
height: 0,
|
||||
color: Colors.transparent,
|
||||
);
|
||||
},
|
||||
itemCount: categories.length);
|
||||
}
|
||||
|
||||
class SettingsPanel extends StatelessWidget {
|
||||
|
@ -43,22 +41,25 @@ class SettingsPanel extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
border: Border.all(color: Theme.of(context).colorScheme.secondary),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
content,
|
||||
],
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
border: Border.all(color: Theme.of(context).colorScheme.secondary),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
content,
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -114,6 +114,7 @@ class _TimelineState extends State<Timeline>
|
|||
onChanged: (dynamic value) {
|
||||
setState(() {
|
||||
selectedId = value ?? global.settings!.activeIdentity;
|
||||
global.settings!.saveActiveIdentity(selectedId);
|
||||
reload();
|
||||
});
|
||||
},
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:loris/partials/post.dart';
|
||||
import '../business_logic/timeline/timeline.dart' as logic;
|
||||
import '../global.dart' as global;
|
||||
|
||||
class Thread extends StatelessWidget {
|
||||
const Thread({required this.model, Key? key}) : super(key: key);
|
||||
|
@ -20,8 +21,10 @@ class Thread extends StatelessWidget {
|
|||
padding: const EdgeInsets.all(4),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(24),
|
||||
width: MediaQuery.of(context).size.width / 1.2,
|
||||
constraints: const BoxConstraints(maxWidth: 1000, minWidth: 375),
|
||||
width: (MediaQuery.of(context).size.width *
|
||||
global.settings!.maxPostWidth) -
|
||||
56,
|
||||
constraints: const BoxConstraints(minWidth: 375),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
border:
|
||||
|
|
Loading…
Reference in New Issue