From a4ab2ec060374ffde319648881f260fe8eb68c0a Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Tue, 12 Apr 2022 14:15:58 -0700 Subject: [PATCH] Themeing Updates including Nicer Code Formatting --- lib/models/messages/textmessage.dart | 2 +- lib/themes/midnight.dart | 2 ++ lib/themes/opaque.dart | 18 ++++++++++++++---- lib/third_party/linkify/flutter_linkify.dart | 8 +++++++- lib/widgets/contactrow.dart | 2 +- lib/widgets/messagebubble.dart | 8 +++++--- 6 files changed, 30 insertions(+), 10 deletions(-) diff --git a/lib/models/messages/textmessage.dart b/lib/models/messages/textmessage.dart index 44f99510..ecfeab70 100644 --- a/lib/models/messages/textmessage.dart +++ b/lib/models/messages/textmessage.dart @@ -19,7 +19,7 @@ class TextMessage extends Message { return ChangeNotifierProvider.value( value: this.metadata, builder: (bcontext, child) { - return Text(this.content); + return SelectableText(this.content); }); } diff --git a/lib/themes/midnight.dart b/lib/themes/midnight.dart index 17a27176..5537c3bb 100644 --- a/lib/themes/midnight.dart +++ b/lib/themes/midnight.dart @@ -18,6 +18,7 @@ OpaqueThemeType GetMidnightTheme(String mode) { class MidnightDark extends CwtchDark { static final Color background = Color(0xFF1B1B1B); + static final Color backgroundAlt = Color(0xFF494949); static final Color header = Color(0xFF1B1B1B); static final Color userBubble = Color(0xFF373737); static final Color peerBubble = Color(0xFF494949); @@ -41,6 +42,7 @@ class MidnightDark extends CwtchDark { get messageFromOtherTextColor => font; //whiteishPurple; get textfieldBackgroundColor => peerBubble; get textfieldBorderColor => userBubble; + get backgroundHilightElementColor => backgroundAlt; } class MidnightLight extends CwtchLight { diff --git a/lib/themes/opaque.dart b/lib/themes/opaque.dart index b71f655e..095ab1d3 100644 --- a/lib/themes/opaque.dart +++ b/lib/themes/opaque.dart @@ -128,8 +128,8 @@ ThemeData mkThemeData(Settings opaque) { primaryIconTheme: IconThemeData( color: opaque.current().mainTextColor, ), - primaryColor: opaque.current().backgroundMainColor, - canvasColor: opaque.current().backgroundPaneColor, + primaryColor: opaque.current().mainTextColor, + canvasColor: opaque.current().backgroundMainColor, backgroundColor: opaque.current().backgroundMainColor, highlightColor: opaque.current().hilightElementColor, iconTheme: IconThemeData( @@ -154,6 +154,7 @@ ThemeData mkThemeData(Settings opaque) { actionsIconTheme: IconThemeData( color: opaque.current().mainTextColor, )), + //bottomNavigationBarTheme: BottomNavigationBarThemeData(type: BottomNavigationBarType.fixed, backgroundColor: opaque.current().backgroundHilightElementColor), // Can't determine current use textButtonTheme: TextButtonThemeData( style: ButtonStyle( @@ -181,7 +182,10 @@ ThemeData mkThemeData(Settings opaque) { ), ), scrollbarTheme: ScrollbarThemeData(isAlwaysShown: false, thumbColor: MaterialStateProperty.all(opaque.current().scrollbarDefaultColor)), - tabBarTheme: TabBarTheme(indicator: UnderlineTabIndicator(borderSide: BorderSide(color: opaque.current().defaultButtonActiveColor))), + tabBarTheme: TabBarTheme( + labelColor: opaque.current().mainTextColor, + unselectedLabelColor: opaque.current().mainTextColor, + indicator: UnderlineTabIndicator(borderSide: BorderSide(color: opaque.current().defaultButtonActiveColor))), dialogTheme: DialogTheme( backgroundColor: opaque.current().backgroundPaneColor, titleTextStyle: TextStyle(color: opaque.current().mainTextColor), @@ -207,8 +211,14 @@ ThemeData mkThemeData(Settings opaque) { thumbColor: MaterialStateProperty.all(opaque.current().mainTextColor), trackColor: MaterialStateProperty.all(opaque.current().dropShadowColor), ), + // the only way to change the text Selection Context Menu Color ?! + brightness: opaque.current().mode == mode_dark ? Brightness.dark : Brightness.light, floatingActionButtonTheme: FloatingActionButtonThemeData( - backgroundColor: opaque.current().defaultButtonColor, hoverColor: opaque.current().defaultButtonActiveColor, enableFeedback: true, splashColor: opaque.current().defaultButtonActiveColor), + foregroundColor: opaque.current().mainTextColor, + backgroundColor: opaque.current().defaultButtonColor, + hoverColor: opaque.current().defaultButtonActiveColor, + enableFeedback: true, + splashColor: opaque.current().defaultButtonActiveColor), textSelectionTheme: TextSelectionThemeData( cursorColor: opaque.current().defaultButtonActiveColor, selectionColor: opaque.current().defaultButtonActiveColor, selectionHandleColor: opaque.current().defaultButtonActiveColor), ); diff --git a/lib/third_party/linkify/flutter_linkify.dart b/lib/third_party/linkify/flutter_linkify.dart index 8aa51542..527c2685 100644 --- a/lib/third_party/linkify/flutter_linkify.dart +++ b/lib/third_party/linkify/flutter_linkify.dart @@ -171,6 +171,9 @@ class SelectableLinkify extends StatelessWidget { // TextSpan + /// Style for code text + final TextStyle? codeStyle; + /// Style for non-link text final TextStyle? style; @@ -255,6 +258,7 @@ class SelectableLinkify extends StatelessWidget { this.linkStyle, // RichText this.textAlign, + this.codeStyle, this.textDirection, this.minLines, this.maxLines, @@ -291,6 +295,7 @@ class SelectableLinkify extends StatelessWidget { buildTextSpan( elements, style: Theme.of(context).textTheme.bodyText2?.merge(style), + codeStyle: Theme.of(context).textTheme.bodyText2?.merge(codeStyle), onOpen: onOpen, linkStyle: Theme.of(context) .textTheme @@ -347,6 +352,7 @@ TextSpan buildTextSpan( List elements, { TextStyle? style, TextStyle? linkStyle, + TextStyle? codeStyle, LinkCallback? onOpen, bool useMouseRegion = false, }) { @@ -404,7 +410,7 @@ TextSpan buildTextSpan( text: element.text.replaceAll("\`", ""), // monospace fonts at the same size as regular text makes them appear // slightly larger, so we compensate by making them slightly smaller... - style: style?.copyWith(fontFamily: "RobotoMono", fontSize: style.fontSize! - 1.0), + style: codeStyle?.copyWith(fontFamily: "RobotoMono", fontSize: codeStyle.fontSize! - 1.5), semanticsLabel: element.text); } else { return TextSpan( diff --git a/lib/widgets/contactrow.dart b/lib/widgets/contactrow.dart index a18f4f03..57dbee25 100644 --- a/lib/widgets/contactrow.dart +++ b/lib/widgets/contactrow.dart @@ -40,7 +40,7 @@ class _ContactRowState extends State { return Card( clipBehavior: Clip.antiAlias, color: Provider.of(context).selectedConversation == contact.identifier ? Provider.of(context).theme.backgroundHilightElementColor : null, - borderOnForeground: false, + borderOnForeground: true, margin: EdgeInsets.all(0.0), child: InkWell( child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ diff --git a/lib/widgets/messagebubble.dart b/lib/widgets/messagebubble.dart index 69a57551..668f1663 100644 --- a/lib/widgets/messagebubble.dart +++ b/lib/widgets/messagebubble.dart @@ -63,9 +63,11 @@ class MessageBubbleState extends State { style: TextStyle( color: fromMe ? Provider.of(context).theme.messageFromMeTextColor : Provider.of(context).theme.messageFromOtherTextColor, ), - linkStyle: TextStyle( - color: Provider.of(context).current().mainTextColor, - ), + linkStyle: TextStyle(color: fromMe ? Provider.of(context).theme.messageFromMeTextColor : Provider.of(context).theme.messageFromOtherTextColor), + codeStyle: TextStyle( + // note: these colors are flipped + color: fromMe ? Provider.of(context).theme.messageFromOtherTextColor : Provider.of(context).theme.messageFromMeTextColor, + backgroundColor: fromMe ? Provider.of(context).theme.messageFromOtherBackgroundColor : Provider.of(context).theme.messageFromMeBackgroundColor), textAlign: TextAlign.left, textWidthBasis: TextWidthBasis.longestLine, );