From b58d00a5f0a6c8107e4eda928df8445aec75f36c Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 28 Dec 2020 15:29:29 +0530 Subject: [PATCH] feat: Added text theme instead of hardcoded styles --- lib/src/date_divider.dart | 10 +++++----- lib/src/file_attachment.dart | 13 +++++-------- lib/src/giphy_attachment.dart | 17 ++++++++++------- lib/src/image_actions_modal.dart | 9 ++++----- lib/src/image_footer.dart | 19 ++++--------------- lib/src/image_header.dart | 6 +----- lib/src/message_input.dart | 17 ++++++++++------- lib/src/message_widget.dart | 8 ++++---- lib/src/url_attachment.dart | 26 ++++++++++++++------------ lib/src/utils.dart | 2 +- 10 files changed, 58 insertions(+), 69 deletions(-) diff --git a/lib/src/date_divider.dart b/lib/src/date_divider.dart index 8fbe5f77..3b8c36c1 100644 --- a/lib/src/date_divider.dart +++ b/lib/src/date_divider.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:jiffy/jiffy.dart'; +import 'package:stream_chat_flutter/src/stream_chat_theme.dart'; /// It shows a date divider depending on the date difference class DateDivider extends StatelessWidget { @@ -49,11 +50,10 @@ class DateDivider extends StatelessWidget { ), child: Text( dayInfo, - style: TextStyle( - fontSize: 12, - color: Colors.white, - fontWeight: FontWeight.bold, - ), + style: StreamChatTheme.of(context).textTheme.footnoteBold.copyWith( + color: Colors.white, + fontWeight: FontWeight.bold, + ), ), ), ); diff --git a/lib/src/file_attachment.dart b/lib/src/file_attachment.dart index 4bba7779..c5e6c92f 100644 --- a/lib/src/file_attachment.dart +++ b/lib/src/file_attachment.dart @@ -88,10 +88,7 @@ class _FileAttachmentState extends State { children: [ Text( widget.attachment?.title ?? 'File', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - ), + style: StreamChatTheme.of(context).textTheme.bodyBold, maxLines: 1, overflow: TextOverflow.ellipsis, ), @@ -100,10 +97,10 @@ class _FileAttachmentState extends State { ), Text( '${_getSizeText(widget.attachment.extraData['file_size'])}', - style: TextStyle( - color: Colors.black.withOpacity(0.5), - fontSize: 14.0, - ), + style: StreamChatTheme.of(context) + .textTheme + .body + .copyWith(color: Colors.black.withOpacity(0.5)), ), ], ), diff --git a/lib/src/giphy_attachment.dart b/lib/src/giphy_attachment.dart index 3e29b2f1..74dfeeb4 100644 --- a/lib/src/giphy_attachment.dart +++ b/lib/src/giphy_attachment.dart @@ -220,9 +220,12 @@ class GiphyAttachment extends StatelessWidget { }, child: Text( 'Cancel', - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.black.withOpacity(0.5)), + style: StreamChatTheme.of(context) + .textTheme + .bodyBold + .copyWith( + color: Colors.black.withOpacity(0.5), + ), ), ), ), @@ -271,10 +274,10 @@ class GiphyAttachment extends StatelessWidget { ), Text( 'Only visible to you', - style: TextStyle( - color: Colors.black.withOpacity(0.5), - fontSize: 12.0, - ), + style: StreamChatTheme.of(context) + .textTheme + .footnote + .copyWith(color: Colors.black.withOpacity(0.5)), ), ], ), diff --git a/lib/src/image_actions_modal.dart b/lib/src/image_actions_modal.dart index fc81635c..2b2aa05e 100644 --- a/lib/src/image_actions_modal.dart +++ b/lib/src/image_actions_modal.dart @@ -66,11 +66,10 @@ class ImageActionsModal extends StatelessWidget { padding: const EdgeInsets.only(top: 8.0), child: Text( userName, - style: TextStyle( - fontSize: 16.0, - fontWeight: FontWeight.w700, - color: Colors.white, - ), + style: StreamChatTheme.of(context) + .textTheme + .headlineBold + .copyWith(color: Colors.white), ), ), Text( diff --git a/lib/src/image_footer.dart b/lib/src/image_footer.dart index 3c37a66a..f16be87d 100644 --- a/lib/src/image_footer.dart +++ b/lib/src/image_footer.dart @@ -130,11 +130,7 @@ class _ImageFooterState extends State { children: [ Text( '${widget.currentPage + 1} of ${widget.totalPages}', - style: TextStyle( - fontSize: 16.0, - fontWeight: FontWeight.w700, - color: Colors.black, - ), + style: StreamChatTheme.of(context).textTheme.headlineBold, ), ], ), @@ -182,11 +178,8 @@ class _ImageFooterState extends State { padding: const EdgeInsets.all(16.0), child: Text( 'Photos', - style: TextStyle( - fontSize: 16.0, - fontWeight: FontWeight.w700, - color: Colors.black, - ), + style: + StreamChatTheme.of(context).textTheme.headlineBold, ), ), ), @@ -490,11 +483,7 @@ class _ImageFooterState extends State { padding: const EdgeInsets.all(16.0), child: Text( 'Select a Chat to Share', - style: TextStyle( - fontSize: 16.0, - fontWeight: FontWeight.w700, - color: Colors.black, - ), + style: StreamChatTheme.of(context).textTheme.headlineBold, ), ), Padding( diff --git a/lib/src/image_header.dart b/lib/src/image_header.dart index 62c3f8ec..aae73057 100644 --- a/lib/src/image_header.dart +++ b/lib/src/image_header.dart @@ -81,11 +81,7 @@ class ImageHeader extends StatelessWidget implements PreferredSizeWidget { children: [ Text( userName, - style: TextStyle( - fontSize: 16.0, - fontWeight: FontWeight.w700, - color: Colors.black, - ), + style: StreamChatTheme.of(context).textTheme.headlineBold, ), Text( sentAt, diff --git a/lib/src/message_input.dart b/lib/src/message_input.dart index 8436d526..e0f290fc 100644 --- a/lib/src/message_input.dart +++ b/lib/src/message_input.dart @@ -423,8 +423,10 @@ class MessageInputState extends State { ), Text( _chosenCommand?.name?.toUpperCase() ?? "", - style: TextStyle( - color: Colors.white, fontSize: 12.0), + style: StreamChatTheme.of(context) + .textTheme + .footnote + .copyWith(color: Colors.white), ), ], ), @@ -899,11 +901,12 @@ class MessageInputState extends State { Center( child: Text( 'Allow access to your gallery', - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.bold, - color: StreamChatTheme.of(context).accentColor, - ), + style: StreamChatTheme.of(context) + .textTheme + .bodyBold + .copyWith( + color: StreamChatTheme.of(context).accentColor, + ), ), ), ], diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index 9d81d679..3eb52e45 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -420,10 +420,10 @@ class _MessageWidgetState extends State { SizedBox(width: 8.0), Text( 'Only visible to you', - style: TextStyle( - color: Colors.black.withOpacity(0.5), - fontSize: 12.0, - ), + style: StreamChatTheme.of(context) + .textTheme + .footnote + .copyWith(color: Colors.black.withOpacity(0.5)), ), ], ), diff --git a/lib/src/url_attachment.dart b/lib/src/url_attachment.dart index ad314455..5ecaa1cc 100644 --- a/lib/src/url_attachment.dart +++ b/lib/src/url_attachment.dart @@ -51,10 +51,12 @@ class UrlAttachment extends StatelessWidget { ), child: Text( hostDisplayName, - style: TextStyle( - fontWeight: FontWeight.w700, - color: Color(0xFF006CFF), - ), + style: StreamChatTheme.of(context) + .textTheme + .bodyBold + .copyWith( + color: Color(0xFF006CFF), + ), ), ), decoration: BoxDecoration( @@ -81,18 +83,18 @@ class UrlAttachment extends StatelessWidget { urlAttachment.title.trim(), maxLines: 1, overflow: TextOverflow.ellipsis, - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 12.0, - ), + style: StreamChatTheme.of(context) + .textTheme + .body + .copyWith(fontWeight: FontWeight.w700), ), if (urlAttachment.text != null) Text( urlAttachment.text, - style: TextStyle( - fontWeight: FontWeight.w400, - fontSize: 12.0, - ), + style: StreamChatTheme.of(context) + .textTheme + .body + .copyWith(fontWeight: FontWeight.w400), ), ], ), diff --git a/lib/src/utils.dart b/lib/src/utils.dart index 681a28aa..60eca678 100644 --- a/lib/src/utils.dart +++ b/lib/src/utils.dart @@ -45,7 +45,7 @@ Future showConfirmationDialog( ), Text( title, - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0), + style: StreamChatTheme.of(context).textTheme.headlineBold, ), SizedBox( height: 7.0,