This commit is contained in:
Salvatore Giordano
2020-12-02 13:19:31 +01:00
parent ac0fc427ae
commit 06b2929c37
16 changed files with 203 additions and 97 deletions
+5 -3
View File
@@ -39,11 +39,13 @@ class _AdvancedOptionsPageState extends State<AdvancedOptionsPage> {
backgroundColor: StreamChatTheme.of(context).primaryColor, backgroundColor: StreamChatTheme.of(context).primaryColor,
elevation: 1, elevation: 1,
centerTitle: true, centerTitle: true,
brightness: Theme.of(context).brightness,
title: Text( title: Text(
'Advanced Options', 'Advanced Options',
style: Theme.of(context).textTheme.subtitle1.copyWith( style: StreamChatTheme.of(context)
fontWeight: FontWeight.bold, .textTheme
), .headlineBold
.copyWith(color: Colors.black),
), ),
leading: IconButton( leading: IconButton(
icon: StreamSvgIcon.left( icon: StreamSvgIcon.left(
+9 -8
View File
@@ -78,10 +78,10 @@ class ChipInputTextFieldState<T> extends State<ChipsInputTextField<T>> {
padding: const EdgeInsets.symmetric(vertical: 4.0), padding: const EdgeInsets.symmetric(vertical: 4.0),
child: Text( child: Text(
'TO:', 'TO:',
style: TextStyle( style: StreamChatTheme.of(context)
fontSize: 12, .textTheme
color: Colors.black.withOpacity(0.5), .footnote
), .copyWith(color: Colors.black.withOpacity(.5)),
), ),
), ),
SizedBox(width: 12), SizedBox(width: 12),
@@ -111,10 +111,11 @@ class ChipInputTextFieldState<T> extends State<ChipsInputTextField<T>> {
disabledBorder: InputBorder.none, disabledBorder: InputBorder.none,
contentPadding: const EdgeInsets.only(top: 4.0), contentPadding: const EdgeInsets.only(top: 4.0),
hintText: widget.hint, hintText: widget.hint,
hintStyle: TextStyle( hintStyle: StreamChatTheme.of(context)
color: Colors.black.withOpacity(0.5), .textTheme
fontSize: 14, .body
), .copyWith(
color: Colors.black.withOpacity(.5)),
), ),
), ),
], ],
+23 -13
View File
@@ -80,19 +80,12 @@ class ChooseUserPage extends StatelessWidget {
padding: const EdgeInsets.only(bottom: 13.0), padding: const EdgeInsets.only(bottom: 13.0),
child: Text( child: Text(
'Welcome to Stream Chat', 'Welcome to Stream Chat',
style: TextStyle( style: StreamChatTheme.of(context).textTheme.title,
fontSize: 22,
color: Colors.black,
fontWeight: FontWeight.bold,
),
), ),
), ),
Text( Text(
'Select a user to try the Flutter SDK:', 'Select a user to try the Flutter SDK:',
style: TextStyle( style: StreamChatTheme.of(context).textTheme.body,
fontSize: 14.5,
color: Colors.black,
),
), ),
Expanded( Expanded(
child: Padding( child: Padding(
@@ -169,9 +162,18 @@ class ChooseUserPage extends StatelessWidget {
), ),
title: Text( title: Text(
user.name, user.name,
style: TextStyle(fontWeight: FontWeight.bold), style:
StreamChatTheme.of(context).textTheme.bodyBold,
),
subtitle: Text(
'Stream test account',
style: StreamChatTheme.of(context)
.textTheme
.footnote
.copyWith(
color: Color(0xff7A7A7A),
),
), ),
subtitle: Text('Stream test account'),
trailing: SvgPicture.asset( trailing: SvgPicture.asset(
'assets/icon_arrow_right.svg', 'assets/icon_arrow_right.svg',
height: 24, height: 24,
@@ -192,9 +194,17 @@ class ChooseUserPage extends StatelessWidget {
), ),
title: Text( title: Text(
'Advanced Options', 'Advanced Options',
style: TextStyle(fontWeight: FontWeight.bold), style: StreamChatTheme.of(context).textTheme.bodyBold,
),
subtitle: Text(
'Custom settings',
style: StreamChatTheme.of(context)
.textTheme
.footnote
.copyWith(
color: Color(0xff7A7A7A),
),
), ),
subtitle: Text('Custom settings'),
trailing: SvgPicture.asset( trailing: SvgPicture.asset(
'assets/icon_arrow_right.svg', 'assets/icon_arrow_right.svg',
height: 24, height: 24,
+3
View File
@@ -123,6 +123,9 @@ class _HomePageState extends State<HomePage> {
bottomNavigationBar: BottomNavigationBar( bottomNavigationBar: BottomNavigationBar(
currentIndex: _currentIndex, currentIndex: _currentIndex,
items: _navBarItems, items: _navBarItems,
selectedLabelStyle: StreamChatTheme.of(context).textTheme.footnoteBold,
unselectedLabelStyle:
StreamChatTheme.of(context).textTheme.footnoteBold,
type: BottomNavigationBarType.fixed, type: BottomNavigationBarType.fixed,
selectedItemColor: Colors.black, selectedItemColor: Colors.black,
unselectedItemColor: Colors.grey, unselectedItemColor: Colors.grey,
+20 -16
View File
@@ -113,10 +113,10 @@ class _NewChatScreenState extends State<NewChatScreen> {
leading: const StreamBackButton(), leading: const StreamBackButton(),
title: Text( title: Text(
'New Chat', 'New Chat',
style: TextStyle( style: StreamChatTheme.of(context)
color: Colors.black, .textTheme
fontSize: 16, .headlineBold
), .copyWith(color: Colors.black),
), ),
centerTitle: true, centerTitle: true,
), ),
@@ -203,10 +203,7 @@ class _NewChatScreenState extends State<NewChatScreen> {
SizedBox(width: 8), SizedBox(width: 8),
Text( Text(
'Create a Group', 'Create a Group',
style: TextStyle( style: StreamChatTheme.of(context).textTheme.bodyBold,
fontWeight: FontWeight.bold,
fontSize: 16,
),
), ),
], ],
), ),
@@ -233,13 +230,13 @@ class _NewChatScreenState extends State<NewChatScreen> {
horizontal: 8, horizontal: 8,
), ),
child: Text( child: Text(
_isSearchActive _isSearchActive
? "Matches for \"$_userNameQuery\"" ? "Matches for \"$_userNameQuery\""
: 'On the platform', : 'On the platform',
style: TextStyle( style: StreamChatTheme.of(context)
color: Colors.black.withOpacity(0.5), .textTheme
), .footnote
), .copyWith(color: Colors.black.withOpacity(.5))),
), ),
), ),
Expanded( Expanded(
@@ -299,7 +296,14 @@ class _NewChatScreenState extends State<NewChatScreen> {
), ),
), ),
Text( Text(
'No user matches these keywords...'), 'No user matches these keywords...',
style: StreamChatTheme.of(context)
.textTheme
.footnote
.copyWith(
color: Colors.black
.withOpacity(.5)),
),
], ],
), ),
), ),
+8 -1
View File
@@ -261,7 +261,14 @@ class _NewGroupChatScreenState extends State<NewGroupChatScreen> {
color: Colors.grey, color: Colors.grey,
), ),
), ),
Text('No user matches these keywords...'), Text(
'No user matches these keywords...',
style: StreamChatTheme.of(context)
.textTheme
.footnote
.copyWith(
color: Colors.black.withOpacity(.5)),
),
], ],
), ),
), ),
+5 -4
View File
@@ -40,6 +40,7 @@ class SearchTextField extends StatelessWidget {
controller: controller, controller: controller,
onChanged: onChanged, onChanged: onChanged,
decoration: InputDecoration( decoration: InputDecoration(
prefixText: ' ',
prefixIconConstraints: BoxConstraints.tight(Size(40, 24)), prefixIconConstraints: BoxConstraints.tight(Size(40, 24)),
prefixIcon: Padding( prefixIcon: Padding(
padding: const EdgeInsets.only( padding: const EdgeInsets.only(
@@ -52,10 +53,10 @@ class SearchTextField extends StatelessWidget {
), ),
), ),
hintText: hintText, hintText: hintText,
hintStyle: TextStyle( hintStyle: StreamChatTheme.of(context)
color: Colors.black.withOpacity(0.5), .textTheme
fontSize: 14, .body
), .copyWith(color: Colors.black.withOpacity(.5)),
contentPadding: const EdgeInsets.all(0), contentPadding: const EdgeInsets.all(0),
border: OutlineInputBorder( border: OutlineInputBorder(
borderSide: BorderSide.none, borderSide: BorderSide.none,
+1 -1
View File
@@ -1,6 +1,6 @@
name: example name: example
description: A new Flutter project. description: A new Flutter project.
version: 1.0.87+89 version: 1.0.88+90
environment: environment:
sdk: ">=2.2.2 <3.0.0" sdk: ">=2.2.2 <3.0.0"
+2 -7
View File
@@ -144,13 +144,8 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget {
Widget _buildConnectedTitleState(BuildContext context) => Text( Widget _buildConnectedTitleState(BuildContext context) => Text(
'Stream Chat', 'Stream Chat',
style: StreamChatTheme.of(context) style: StreamChatTheme.of(context).textTheme.headlineBold.copyWith(
.channelTheme color: Colors.black,
.channelHeaderTheme
.title
.copyWith(
fontSize: 16,
fontWeight: FontWeight.bold,
), ),
); );
+16 -12
View File
@@ -210,9 +210,9 @@ class _ChannelListViewState extends State<ChannelListView>
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Text( child: Text(
'Lets start chatting!', 'Lets start chatting!',
style: TextStyle( style: StreamChatTheme.of(context)
fontSize: 16, .textTheme
), .headline,
), ),
), ),
Padding( Padding(
@@ -223,10 +223,12 @@ class _ChannelListViewState extends State<ChannelListView>
child: Text( child: Text(
'How about sending your first message to a friend?', 'How about sending your first message to a friend?',
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: StreamChatTheme.of(context)
fontSize: 14, .textTheme
color: Color(0xff7A7A7A), .body
), .copyWith(
color: Color(0xff7A7A7A),
),
), ),
), ),
], ],
@@ -242,11 +244,13 @@ class _ChannelListViewState extends State<ChannelListView>
onPressed: widget.onStartChatPressed, onPressed: widget.onStartChatPressed,
child: Text( child: Text(
'Start a chat', 'Start a chat',
style: TextStyle( style: StreamChatTheme.of(context)
color: .textTheme
StreamChatTheme.of(context).accentColor, .bodyBold
fontWeight: FontWeight.bold, .copyWith(
), color: StreamChatTheme.of(context)
.accentColor,
),
), ),
), ),
), ),
+3
View File
@@ -49,6 +49,9 @@ class ChannelPreview extends StatelessWidget {
return Opacity( return Opacity(
opacity: snapshot.data ? 0.5 : 1, opacity: snapshot.data ? 0.5 : 1,
child: ListTile( child: ListTile(
contentPadding: const EdgeInsets.symmetric(
horizontal: 8,
),
onTap: () { onTap: () {
if (onTap != null) { if (onTap != null) {
onTap(channel); onTap(channel);
+4 -4
View File
@@ -195,10 +195,10 @@ class _MessageListViewState extends State<MessageListView> {
return Center( return Center(
child: Text( child: Text(
'No chats here yet...', 'No chats here yet...',
style: TextStyle( style: StreamChatTheme.of(context)
fontSize: 12, .textTheme
color: Colors.black.withOpacity(.5), .footnote
), .copyWith(color: Colors.black.withOpacity(.5)),
), ),
); );
} }
-2
View File
@@ -126,8 +126,6 @@ class MessageSearchItem extends StatelessWidget {
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( style: StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith(
color:
StreamChatTheme.of(context).channelPreviewTheme.subtitle.color,
fontStyle: (message.isSystem || message.isDeleted) fontStyle: (message.isSystem || message.isDeleted)
? FontStyle.italic ? FontStyle.italic
: FontStyle.normal, : FontStyle.normal,
+95 -23
View File
@@ -42,6 +42,9 @@ class StreamChatTheme extends InheritedWidget {
/// Theme data /// Theme data
class StreamChatThemeData { class StreamChatThemeData {
/// The text themes used in the widgets
final TextTheme textTheme;
/// Primary color of the chat widgets /// Primary color of the chat widgets
final Color primaryColor; final Color primaryColor;
@@ -80,6 +83,7 @@ class StreamChatThemeData {
/// Create a theme from scratch /// Create a theme from scratch
StreamChatThemeData({ StreamChatThemeData({
this.textTheme,
this.primaryColor, this.primaryColor,
this.secondaryColor, this.secondaryColor,
this.accentColor, this.accentColor,
@@ -131,6 +135,7 @@ class StreamChatThemeData {
/// Creates a copy of [StreamChatThemeData] with specified attributes overridden. /// Creates a copy of [StreamChatThemeData] with specified attributes overridden.
StreamChatThemeData copyWith({ StreamChatThemeData copyWith({
TextTheme textTheme,
Color primaryColor, Color primaryColor,
Color secondaryColor, Color secondaryColor,
Color accentColor, Color accentColor,
@@ -145,6 +150,16 @@ class StreamChatThemeData {
List<ReactionIcon> reactionIcons, List<ReactionIcon> reactionIcons,
}) => }) =>
StreamChatThemeData( StreamChatThemeData(
textTheme: this.textTheme?.copyWith(
title: textTheme?.title,
body: textTheme?.body,
bodyBold: textTheme?.bodyBold,
captionBold: textTheme?.captionBold,
footnote: textTheme?.footnote,
footnoteBold: textTheme?.footnoteBold,
headline: textTheme?.headline,
headlineBold: textTheme?.headlineBold,
),
primaryColor: primaryColor ?? this.primaryColor, primaryColor: primaryColor ?? this.primaryColor,
secondaryColor: secondaryColor ?? this.secondaryColor, secondaryColor: secondaryColor ?? this.secondaryColor,
primaryIconTheme: primaryIconTheme ?? this.primaryIconTheme, primaryIconTheme: primaryIconTheme ?? this.primaryIconTheme,
@@ -152,17 +167,12 @@ class StreamChatThemeData {
defaultChannelImage: defaultChannelImage ?? this.defaultChannelImage, defaultChannelImage: defaultChannelImage ?? this.defaultChannelImage,
defaultUserImage: defaultUserImage ?? this.defaultUserImage, defaultUserImage: defaultUserImage ?? this.defaultUserImage,
backgroundColor: backgroundColor ?? this.backgroundColor, backgroundColor: backgroundColor ?? this.backgroundColor,
channelPreviewTheme: channelPreviewTheme?.copyWith( channelPreviewTheme: this.channelPreviewTheme?.copyWith(
title: title: channelPreviewTheme.title,
channelPreviewTheme.title ?? this.channelPreviewTheme.title, subtitle: channelPreviewTheme.subtitle,
subtitle: channelPreviewTheme.subtitle ?? lastMessageAt: channelPreviewTheme.lastMessageAt,
this.channelPreviewTheme.subtitle, avatarTheme: channelPreviewTheme.avatarTheme,
lastMessageAt: channelPreviewTheme.lastMessageAt ?? ),
this.channelPreviewTheme.lastMessageAt,
avatarTheme: channelPreviewTheme.avatarTheme ??
this.channelPreviewTheme.avatarTheme,
) ??
this.channelPreviewTheme,
channelTheme: channelTheme?.copyWith( channelTheme: channelTheme?.copyWith(
channelHeaderTheme: channelTheme.channelHeaderTheme ?? channelHeaderTheme: channelTheme.channelHeaderTheme ??
this.channelTheme.channelHeaderTheme, this.channelTheme.channelHeaderTheme,
@@ -218,7 +228,9 @@ class StreamChatThemeData {
static StreamChatThemeData getDefaultTheme(ThemeData theme) { static StreamChatThemeData getDefaultTheme(ThemeData theme) {
final accentColor = Color(0xff006cff); final accentColor = Color(0xff006cff);
final isDark = theme.brightness == Brightness.dark; final isDark = theme.brightness == Brightness.dark;
final textTheme = TextTheme();
return StreamChatThemeData( return StreamChatThemeData(
textTheme: textTheme,
secondaryColor: Color(0xffEAEAEA), secondaryColor: Color(0xffEAEAEA),
accentColor: accentColor, accentColor: accentColor,
primaryColor: isDark ? Colors.black : Colors.white, primaryColor: isDark ? Colors.black : Colors.white,
@@ -242,19 +254,12 @@ class StreamChatThemeData {
width: 40, width: 40,
), ),
), ),
title: TextStyle( title: textTheme.bodyBold,
fontSize: 14, subtitle: textTheme.footnote.copyWith(
color: isDark ? Colors.white : Colors.black, color: Color(0xff7A7A7A),
fontWeight: FontWeight.bold),
subtitle: TextStyle(
fontSize: 12.5,
color: (isDark ? Colors.white : Colors.black).withOpacity(0.5),
), ),
lastMessageAt: TextStyle( lastMessageAt: textTheme.footnote.copyWith(
fontSize: 11, color: Colors.black.withOpacity(.5),
color: isDark
? Colors.white.withOpacity(.5)
: Colors.black.withOpacity(.5),
), ),
), ),
channelTheme: ChannelTheme( channelTheme: ChannelTheme(
@@ -375,6 +380,73 @@ class StreamChatThemeData {
} }
} }
class TextTheme {
final TextStyle title;
final TextStyle headlineBold;
final TextStyle headline;
final TextStyle bodyBold;
final TextStyle body;
final TextStyle footnoteBold;
final TextStyle footnote;
final TextStyle captionBold;
TextTheme({
this.title = const TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
),
this.headlineBold = const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
this.headline = const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
),
this.bodyBold = const TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
),
this.body = const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
),
this.footnoteBold = const TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
),
this.footnote = const TextStyle(
fontSize: 12,
),
this.captionBold = const TextStyle(
fontSize: 10,
fontWeight: FontWeight.bold,
),
});
TextTheme copyWith({
TextStyle body,
TextStyle title,
TextStyle headlineBold,
TextStyle headline,
TextStyle bodyBold,
TextStyle footnoteBold,
TextStyle footnote,
TextStyle captionBold,
}) {
return TextTheme(
body: body ?? this.body,
title: title ?? this.title,
headlineBold: headlineBold ?? this.headlineBold,
headline: headline ?? this.headline,
bodyBold: bodyBold ?? this.bodyBold,
footnoteBold: footnoteBold ?? this.footnoteBold,
footnote: footnote ?? this.footnote,
captionBold: captionBold ?? this.captionBold,
);
}
}
/// Channel theme data /// Channel theme data
class ChannelTheme { class ChannelTheme {
/// Theme of the [ChannelHeader] widget /// Theme of the [ChannelHeader] widget
+8 -2
View File
@@ -83,13 +83,19 @@ class UserItem extends StatelessWidget {
: null, : null,
title: Text( title: Text(
user.name, user.name,
style: TextStyle(fontWeight: FontWeight.bold), style: StreamChatTheme.of(context).textTheme.bodyBold,
), ),
subtitle: showLastOnline ? _buildLastActive(context) : null, subtitle: showLastOnline ? _buildLastActive(context) : null,
); );
} }
Widget _buildLastActive(context) { Widget _buildLastActive(context) {
return Text('Last online ${Jiffy(user.lastActive).fromNow()}'); return Text(
'Last online ${Jiffy(user.lastActive).fromNow()}',
style: StreamChatTheme.of(context)
.textTheme
.footnote
.copyWith(color: Colors.black.withOpacity(.5)),
);
} }
} }
+1 -1
View File
@@ -361,7 +361,7 @@ class _UserListViewState extends State<UserListView>
header, header,
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 12, fontSize: 14.5,
color: Colors.black.withOpacity(0.3)), color: Colors.black.withOpacity(0.3)),
), ),
), ),