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

View file

@ -51,13 +51,17 @@ Widget _createNewChatButton(
ChatTranslations translations,
) =>
Padding(
padding: const EdgeInsets.all(16.0),
padding: const EdgeInsets.all(24.0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.black,
minimumSize: const Size.fromHeight(50),
),
onPressed: onPressed,
child: Text(translations.newChatButton),
child: Text(
translations.newChatButton,
style: const TextStyle(color: Colors.white),
),
),
);
@ -67,10 +71,38 @@ Widget _createMessageInput(
ChatTranslations translations,
) =>
TextField(
textCapitalization: TextCapitalization.sentences,
controller: textEditingController,
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,
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,
),
);
@ -95,9 +127,13 @@ Widget _createImagePickerContainer(
color: Colors.white,
child: ImagePicker(
customButton: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.black,
),
onPressed: onClose,
child: Text(
translations.cancelImagePickerBtn,
style: const TextStyle(color: Colors.white),
),
),
),

View file

@ -137,6 +137,8 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
@override
Widget build(BuildContext context) {
var theme = Theme.of(context);
Future<void> onPressSelectImage() async => showModalBottomSheet<Uint8List?>(
context: context,
builder: (BuildContext context) =>
@ -166,6 +168,9 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
var chatModel = snapshot.data;
return Scaffold(
appBar: AppBar(
backgroundColor: theme.appBarTheme.backgroundColor ?? Colors.black,
iconTheme: theme.appBarTheme.iconTheme ??
const IconThemeData(color: Colors.white),
centerTitle: true,
title: GestureDetector(
onTap: () => widget.onPressChatTitle.call(context, chatModel!),
@ -208,7 +213,10 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
widget
.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) {
var size = MediaQuery.of(context).size;
var hasUser = widget.userId == null;
var theme = Theme.of(context);
return FutureBuilder<dynamic>(
future: hasUser
// ignore: discarded_futures
@ -69,6 +70,9 @@ class _ProfileScreenState extends State<ChatProfileScreen> {
return Scaffold(
appBar: AppBar(
backgroundColor: theme.appBarTheme.backgroundColor ?? Colors.black,
iconTheme: theme.appBarTheme.iconTheme ??
const IconThemeData(color: Colors.white),
title: Text(
(data is ChatUserModel)
? '${data.firstName ?? ''} ${data.lastName ?? ''}'
@ -77,6 +81,10 @@ class _ProfileScreenState extends State<ChatProfileScreen> {
: (data is GroupChatModel)
? data.title
: '',
style: theme.appBarTheme.titleTextStyle ??
const TextStyle(
color: Colors.white,
),
),
),
body: snapshot.hasData

View file

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

View file

@ -36,63 +36,100 @@ class _NewChatScreenState extends State<NewChatScreen> {
String query = '';
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: _buildSearchField(),
actions: [
_buildSearchIcon(),
],
),
body: FutureBuilder<List<ChatUserModel>>(
// ignore: discarded_futures
future: widget.service.chatUserService.getAllUsers(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
} else if (snapshot.hasError) {
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();
Widget build(BuildContext context) {
var theme = Theme.of(context);
return Scaffold(
appBar: AppBar(
iconTheme: theme.appBarTheme.iconTheme ??
const IconThemeData(color: Colors.white),
backgroundColor: theme.appBarTheme.backgroundColor ?? Colors.black,
title: _buildSearchField(),
actions: [
_buildSearchIcon(),
],
),
body: FutureBuilder<List<ChatUserModel>>(
// ignore: discarded_futures
future: widget.service.chatUserService.getAllUsers(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
} else if (snapshot.hasError) {
return Text('Error: ${snapshot.error}');
} else if (snapshot.hasData) {
return _buildUserList(snapshot.data!);
} else {
return widget.options
.noChatsPlaceholderBuilder(widget.translations);
}
},
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) {
var filteredUsers = users