fix: updated the default styling

This commit is contained in:
mike doornenbal 2024-02-28 14:58:48 +01:00 committed by Vick Top
parent 5052d016da
commit baefa03a94
6 changed files with 160 additions and 63 deletions

View file

@ -21,7 +21,7 @@ class ChatUserStoryConfiguration {
this.onReadChat, this.onReadChat,
this.onUploadImage, this.onUploadImage,
this.onPressCreateChat, this.onPressCreateChat,
this.iconColor, this.iconColor = Colors.black,
this.deleteChatDialog, this.deleteChatDialog,
this.disableDismissForPermanentChats = false, this.disableDismissForPermanentChats = false,
this.routeToNewChatIfEmpty = true, this.routeToNewChatIfEmpty = true,
@ -31,7 +31,7 @@ class ChatUserStoryConfiguration {
this.afterMessageSent, this.afterMessageSent,
this.messagePageSize = 20, this.messagePageSize = 20,
this.onPressUserProfile, this.onPressUserProfile,
this.textfieldBottomPadding = 0, this.textfieldBottomPadding = 20,
this.iconDisabledColor = Colors.grey, this.iconDisabledColor = Colors.grey,
this.unreadMessageTextStyle, this.unreadMessageTextStyle,
this.loadingWidgetBuilder, this.loadingWidgetBuilder,

View file

@ -51,13 +51,17 @@ Widget _createNewChatButton(
ChatTranslations translations, ChatTranslations translations,
) => ) =>
Padding( Padding(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(24.0),
child: ElevatedButton( child: ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: Colors.black,
minimumSize: const Size.fromHeight(50), minimumSize: const Size.fromHeight(50),
), ),
onPressed: onPressed, onPressed: onPressed,
child: Text(translations.newChatButton), child: Text(
translations.newChatButton,
style: const TextStyle(color: Colors.white),
),
), ),
); );
@ -67,10 +71,38 @@ Widget _createMessageInput(
ChatTranslations translations, ChatTranslations translations,
) => ) =>
TextField( TextField(
textCapitalization: TextCapitalization.sentences,
controller: textEditingController, controller: textEditingController,
decoration: InputDecoration( decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(26.5),
borderSide: const BorderSide(
color: Colors.black,
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(26.5),
borderSide: const BorderSide(
color: Colors.black,
),
),
contentPadding: const EdgeInsets.symmetric(
vertical: 0,
horizontal: 30,
),
hintText: translations.messagePlaceholder, hintText: translations.messagePlaceholder,
hintStyle: const TextStyle(
fontWeight: FontWeight.normal,
color: Colors.black,
),
fillColor: Colors.white,
filled: true,
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(26.5),
),
borderSide: BorderSide.none,
),
suffixIcon: suffixIcon, suffixIcon: suffixIcon,
), ),
); );
@ -95,9 +127,13 @@ Widget _createImagePickerContainer(
color: Colors.white, color: Colors.white,
child: ImagePicker( child: ImagePicker(
customButton: ElevatedButton( customButton: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.black,
),
onPressed: onClose, onPressed: onClose,
child: Text( child: Text(
translations.cancelImagePickerBtn, translations.cancelImagePickerBtn,
style: const TextStyle(color: Colors.white),
), ),
), ),
), ),

View file

@ -137,6 +137,8 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var theme = Theme.of(context);
Future<void> onPressSelectImage() async => showModalBottomSheet<Uint8List?>( Future<void> onPressSelectImage() async => showModalBottomSheet<Uint8List?>(
context: context, context: context,
builder: (BuildContext context) => builder: (BuildContext context) =>
@ -166,6 +168,9 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
var chatModel = snapshot.data; var chatModel = snapshot.data;
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
backgroundColor: theme.appBarTheme.backgroundColor ?? Colors.black,
iconTheme: theme.appBarTheme.iconTheme ??
const IconThemeData(color: Colors.white),
centerTitle: true, centerTitle: true,
title: GestureDetector( title: GestureDetector(
onTap: () => widget.onPressChatTitle.call(context, chatModel!), onTap: () => widget.onPressChatTitle.call(context, chatModel!),
@ -208,7 +213,10 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
widget widget
.translations.anonymousUser .translations.anonymousUser
: '', : '',
style: const TextStyle(fontSize: 18), style: theme.appBarTheme.titleTextStyle ??
const TextStyle(
color: Colors.white,
),
), ),
), ),
), ),

View file

@ -37,6 +37,7 @@ class _ProfileScreenState extends State<ChatProfileScreen> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
var size = MediaQuery.of(context).size; var size = MediaQuery.of(context).size;
var hasUser = widget.userId == null; var hasUser = widget.userId == null;
var theme = Theme.of(context);
return FutureBuilder<dynamic>( return FutureBuilder<dynamic>(
future: hasUser future: hasUser
// ignore: discarded_futures // ignore: discarded_futures
@ -69,6 +70,9 @@ class _ProfileScreenState extends State<ChatProfileScreen> {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
backgroundColor: theme.appBarTheme.backgroundColor ?? Colors.black,
iconTheme: theme.appBarTheme.iconTheme ??
const IconThemeData(color: Colors.white),
title: Text( title: Text(
(data is ChatUserModel) (data is ChatUserModel)
? '${data.firstName ?? ''} ${data.lastName ?? ''}' ? '${data.firstName ?? ''} ${data.lastName ?? ''}'
@ -77,6 +81,10 @@ class _ProfileScreenState extends State<ChatProfileScreen> {
: (data is GroupChatModel) : (data is GroupChatModel)
? data.title ? data.title
: '', : '',
style: theme.appBarTheme.titleTextStyle ??
const TextStyle(
color: Colors.white,
),
), ),
), ),
body: snapshot.hasData body: snapshot.hasData

View file

@ -74,9 +74,17 @@ class _ChatScreenState extends State<ChatScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var translations = widget.translations; var translations = widget.translations;
var theme = Theme.of(context);
return widget.options.scaffoldBuilder( return widget.options.scaffoldBuilder(
AppBar( AppBar(
title: Text(translations.chatsTitle), backgroundColor: theme.appBarTheme.backgroundColor ?? Colors.black,
title: Text(
translations.chatsTitle,
style: theme.appBarTheme.titleTextStyle ??
const TextStyle(
color: Colors.white,
),
),
centerTitle: true, centerTitle: true,
actions: [ actions: [
StreamBuilder<int>( StreamBuilder<int>(
@ -90,7 +98,7 @@ class _ChatScreenState extends State<ChatScreen> {
'${snapshot.data ?? 0} ${translations.chatsUnread}', '${snapshot.data ?? 0} ${translations.chatsUnread}',
style: widget.unreadMessageTextStyle ?? style: widget.unreadMessageTextStyle ??
const TextStyle( const TextStyle(
color: Color(0xFFBBBBBB), color: Colors.white,
fontSize: 14, fontSize: 14,
), ),
), ),

View file

@ -36,63 +36,100 @@ class _NewChatScreenState extends State<NewChatScreen> {
String query = ''; String query = '';
@override @override
Widget build(BuildContext context) => Scaffold( Widget build(BuildContext context) {
appBar: AppBar( var theme = Theme.of(context);
title: _buildSearchField(), return Scaffold(
actions: [ appBar: AppBar(
_buildSearchIcon(), iconTheme: theme.appBarTheme.iconTheme ??
], const IconThemeData(color: Colors.white),
), backgroundColor: theme.appBarTheme.backgroundColor ?? Colors.black,
body: FutureBuilder<List<ChatUserModel>>( title: _buildSearchField(),
// ignore: discarded_futures actions: [
future: widget.service.chatUserService.getAllUsers(), _buildSearchIcon(),
builder: (context, snapshot) { ],
if (snapshot.connectionState == ConnectionState.waiting) { ),
return const Center(child: CircularProgressIndicator()); body: FutureBuilder<List<ChatUserModel>>(
} else if (snapshot.hasError) { // ignore: discarded_futures
return Text('Error: ${snapshot.error}'); future: widget.service.chatUserService.getAllUsers(),
} else if (snapshot.hasData) { builder: (context, snapshot) {
return _buildUserList(snapshot.data!); if (snapshot.connectionState == ConnectionState.waiting) {
} else { return const Center(child: CircularProgressIndicator());
return widget.options } else if (snapshot.hasError) {
.noChatsPlaceholderBuilder(widget.translations); return Text('Error: ${snapshot.error}');
} } else if (snapshot.hasData) {
}, return _buildUserList(snapshot.data!);
), } else {
); return widget.options
.noChatsPlaceholderBuilder(widget.translations);
Widget _buildSearchField() => _isSearching
? Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: TextField(
focusNode: _textFieldFocusNode,
onChanged: (value) {
setState(() {
query = value;
});
},
decoration: InputDecoration(
hintText: widget.translations.searchPlaceholder,
),
),
)
: Text(widget.translations.newChatButton);
Widget _buildSearchIcon() => IconButton(
onPressed: () {
setState(() {
_isSearching = !_isSearching;
query = '';
});
if (_isSearching) {
_textFieldFocusNode.requestFocus();
} }
}, },
icon: Icon( ),
_isSearching ? Icons.close : Icons.search, );
), }
);
Widget _buildSearchField() {
var theme = Theme.of(context);
return _isSearching
? Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: TextField(
focusNode: _textFieldFocusNode,
onChanged: (value) {
setState(() {
query = value;
});
},
decoration: InputDecoration(
hintText: widget.translations.searchPlaceholder,
hintStyle: theme.inputDecorationTheme.hintStyle ??
const TextStyle(
color: Colors.white,
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: theme.inputDecorationTheme.focusedBorder?.borderSide
.color ??
Colors.white,
),
),
),
style: theme.inputDecorationTheme.hintStyle ??
const TextStyle(
color: Colors.white,
),
cursorColor: theme.textSelectionTheme.cursorColor ?? Colors.white,
),
)
: Text(
widget.translations.newChatButton,
style: theme.appBarTheme.titleTextStyle ??
const TextStyle(
color: Colors.white,
),
);
}
Widget _buildSearchIcon() {
var theme = Theme.of(context);
return IconButton(
onPressed: () {
setState(() {
_isSearching = !_isSearching;
query = '';
});
if (_isSearching) {
_textFieldFocusNode.requestFocus();
}
},
icon: Icon(
_isSearching ? Icons.close : Icons.search,
color: theme.appBarTheme.iconTheme?.color ?? Colors.white,
),
);
}
Widget _buildUserList(List<ChatUserModel> users) { Widget _buildUserList(List<ChatUserModel> users) {
var filteredUsers = users var filteredUsers = users