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( Row(
children: [ children: [
const Icon(Icons.repeat), const Icon(Icons.repeat),
Flexible(child: SelectableText("reblogged-by".i18n())), Flexible(
child: SelectableText("reblogged-by".i18n()),
),
], ],
), ),
const SizedBox(
height: 8,
),
DisplayName(account: account!), DisplayName(account: account!),
], ],
); );
@ -160,25 +165,32 @@ class _PostBodyState extends State<PostBody> {
children: [ children: [
Visibility( Visibility(
visible: widget.sensitive, visible: widget.sensitive,
child: Text(widget.spoilerText), child: SelectableText.rich(
), TextSpan(
Visibility( text: "",
visible: widget.sensitive, children: [
child: OutlinedButton.icon( WidgetSpan(
onPressed: () { child: OutlinedButton.icon(
setState(() { onPressed: () {
visible = !visible; setState(() {
if (visible) { visible = !visible;
cwButtonIcon = const Icon(Icons.visibility_off); if (visible) {
cwButtonText = "hide".i18n(); cwButtonIcon = const Icon(Icons.visibility_off);
} else { cwButtonText = "hide".i18n();
cwButtonText = "show".i18n(); } else {
cwButtonIcon = const Icon(Icons.visibility); cwButtonText = "show".i18n();
} cwButtonIcon = const Icon(Icons.visibility);
}); }
}, });
icon: cwButtonIcon, },
label: Text(cwButtonText)), icon: cwButtonIcon,
label: Text(cwButtonText),
),
),
TextSpan(text: widget.spoilerText),
],
),
),
), ),
Visibility( Visibility(
visible: visible, visible: visible,

View File

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

View File

@ -17,8 +17,8 @@ themes.CustomColors theme = themes.CustomColors(
onSecondary: Color.fromARGB(255, 40, 42, 54), onSecondary: Color.fromARGB(255, 40, 42, 54),
error: Color.fromARGB(255, 255, 85, 85), error: Color.fromARGB(255, 255, 85, 85),
onError: Color.fromARGB(255, 40, 42, 54), 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), 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), onSurface: Color.fromARGB(255, 248, 248, 242),
)); ));

View File

@ -1,6 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'dracula.dart' as color_dracula; 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]; final available = [color_dracula.theme];
ThemeData getTheme(CustomColors colors) { ThemeData getTheme(CustomColors colors) {
return ThemeData( return ThemeData(
@ -15,7 +17,7 @@ ThemeData getTheme(CustomColors colors) {
fontSize: 18, fontSize: 18,
), ),
bodySmall: TextStyle( bodySmall: TextStyle(
color: colors.colorScheme.onSurface, color: colors.colorScheme.secondary,
fontSize: 14, fontSize: 14,
), ),
displayLarge: TextStyle( displayLarge: TextStyle(
@ -46,6 +48,25 @@ ThemeData getTheme(CustomColors colors) {
fontSize: 24, 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( textButtonTheme: TextButtonThemeData(
style: ButtonStyle( style: ButtonStyle(
textStyle: MaterialStateProperty.all( textStyle: MaterialStateProperty.all(
@ -70,17 +91,21 @@ ThemeData getTheme(CustomColors colors) {
elevation: 0, elevation: 0,
), ),
navigationBarTheme: NavigationBarThemeData( navigationBarTheme: NavigationBarThemeData(
labelTextStyle: MaterialStateProperty.all(TextStyle( labelTextStyle: MaterialStateProperty.all(
color: colors.colorScheme.onSurface, TextStyle(
fontSize: 14, color: colors.colorScheme.onSurface,
)), fontSize: 14,
),
),
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected, labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected,
indicatorColor: Colors.transparent, indicatorColor: Colors.transparent,
elevation: 0, elevation: 0,
height: 64, height: 64,
), ),
scrollbarTheme: const ScrollbarThemeData(), scrollbarTheme: ScrollbarThemeData(
thumbColor: MaterialStateProperty.all(colors.hintColor),
),
); );
} }