From 853ec95f379d4ccc6a403911447a0a47efd3db70 Mon Sep 17 00:00:00 2001 From: zoe Date: Fri, 12 Aug 2022 21:30:58 +0200 Subject: [PATCH] better content warnings --- lib/partials/post.dart | 52 +++++++++++++++++----------- lib/partials/post_text_renderer.dart | 12 ++++--- lib/themes/dracula.dart | 4 +-- lib/themes/themes.dart | 37 ++++++++++++++++---- 4 files changed, 72 insertions(+), 33 deletions(-) diff --git a/lib/partials/post.dart b/lib/partials/post.dart index b817ccb..882ce93 100644 --- a/lib/partials/post.dart +++ b/lib/partials/post.dart @@ -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 { 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, diff --git a/lib/partials/post_text_renderer.dart b/lib/partials/post_text_renderer.dart index 3768081..bf460d9 100644 --- a/lib/partials/post_text_renderer.dart +++ b/lib/partials/post_text_renderer.dart @@ -14,11 +14,13 @@ class PostTextRenderer extends StatelessWidget { dom.Document document = parser.parse(htmlInput); final List 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, + ), + ); } } diff --git a/lib/themes/dracula.dart b/lib/themes/dracula.dart index 6d2b815..0653377 100644 --- a/lib/themes/dracula.dart +++ b/lib/themes/dracula.dart @@ -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), )); diff --git a/lib/themes/themes.dart b/lib/themes/themes.dart index 02a8e60..22f841b 100644 --- a/lib/themes/themes.dart +++ b/lib/themes/themes.dart @@ -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), + ), ); }