better content warnings

This commit is contained in:
zoe 2022-08-12 21:30:58 +02:00
parent 331d3a584d
commit 853ec95f37
4 changed files with 72 additions and 33 deletions

View File

@ -88,9 +88,14 @@ class RebloggedBy extends StatelessWidget {
Row(
children: [
const Icon(Icons.repeat),
Flexible(child: SelectableText("reblogged-by".i18n())),
Flexible(
child: SelectableText("reblogged-by".i18n()),
),
],
),
const SizedBox(
height: 8,
),
DisplayName(account: account!),
],
);
@ -160,25 +165,32 @@ class _PostBodyState extends State<PostBody> {
children: [
Visibility(
visible: widget.sensitive,
child: Text(widget.spoilerText),
),
Visibility(
visible: widget.sensitive,
child: 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: cwButtonIcon,
label: Text(cwButtonText)),
child: SelectableText.rich(
TextSpan(
text: "",
children: [
WidgetSpan(
child: 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: cwButtonIcon,
label: Text(cwButtonText),
),
),
TextSpan(text: widget.spoilerText),
],
),
),
),
Visibility(
visible: visible,

View File

@ -14,11 +14,13 @@ class PostTextRenderer extends StatelessWidget {
dom.Document document = parser.parse(htmlInput);
final List<InlineSpan> children =
createSpansFromDoc(document.body!.children);
return SelectableText.rich(TextSpan(
style: Theme.of(context).textTheme.bodyMedium,
text: "",
children: children,
));
return SelectableText.rich(
TextSpan(
style: Theme.of(context).textTheme.bodyMedium,
text: "",
children: children,
),
);
}
}

View File

@ -17,8 +17,8 @@ themes.CustomColors theme = themes.CustomColors(
onSecondary: Color.fromARGB(255, 40, 42, 54),
error: Color.fromARGB(255, 255, 85, 85),
onError: Color.fromARGB(255, 40, 42, 54),
background: Color.fromARGB(255, 40, 42, 54),
background: Color.fromARGB(255, 68, 71, 90),
onBackground: Color.fromARGB(255, 248, 248, 242),
surface: Color.fromARGB(255, 68, 71, 90),
surface: Color.fromARGB(255, 40, 42, 54),
onSurface: Color.fromARGB(255, 248, 248, 242),
));

View File

@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'dracula.dart' as color_dracula;
// color schemes to pick from can be added here
// there is a class to create these
final available = [color_dracula.theme];
ThemeData getTheme(CustomColors colors) {
return ThemeData(
@ -15,7 +17,7 @@ ThemeData getTheme(CustomColors colors) {
fontSize: 18,
),
bodySmall: TextStyle(
color: colors.colorScheme.onSurface,
color: colors.colorScheme.secondary,
fontSize: 14,
),
displayLarge: TextStyle(
@ -46,6 +48,25 @@ ThemeData getTheme(CustomColors colors) {
fontSize: 24,
),
),
iconTheme: IconThemeData(
color: colors.colorScheme.onSurface,
),
outlinedButtonTheme: OutlinedButtonThemeData(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
colors.colorScheme.primary,
),
foregroundColor: MaterialStateProperty.all(
colors.colorScheme.onPrimary,
),
textStyle: MaterialStateProperty.all(
const TextStyle(
fontSize: 18,
fontWeight: FontWeight.w700,
),
),
),
),
textButtonTheme: TextButtonThemeData(
style: ButtonStyle(
textStyle: MaterialStateProperty.all(
@ -70,17 +91,21 @@ ThemeData getTheme(CustomColors colors) {
elevation: 0,
),
navigationBarTheme: NavigationBarThemeData(
labelTextStyle: MaterialStateProperty.all(TextStyle(
color: colors.colorScheme.onSurface,
fontSize: 14,
)),
labelTextStyle: MaterialStateProperty.all(
TextStyle(
color: colors.colorScheme.onSurface,
fontSize: 14,
),
),
backgroundColor: Colors.transparent,
labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected,
indicatorColor: Colors.transparent,
elevation: 0,
height: 64,
),
scrollbarTheme: const ScrollbarThemeData(),
scrollbarTheme: ScrollbarThemeData(
thumbColor: MaterialStateProperty.all(colors.hintColor),
),
);
}