Added custom Appbar for each page
This commit is contained in:
@ -36,71 +36,82 @@ class _ChatListState extends State<ChatList> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Consumer<ChatListProps>(
|
||||
builder: (context, data, child) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text("Talk"),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.search),
|
||||
onPressed: () => {},
|
||||
)
|
||||
],
|
||||
),
|
||||
body: Consumer<ChatListProps>(
|
||||
builder: (context, data, child) {
|
||||
|
||||
if(data.primaryLoading()) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
if(data.primaryLoading()) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
List<ListTile> chats = List<ListTile>.empty(growable: true);
|
||||
List<ListTile> chats = List<ListTile>.empty(growable: true);
|
||||
|
||||
for (var chatRoom in data.getRoomsResponse.sortByLastActivity()) {
|
||||
for (var chatRoom in data.getRoomsResponse.sortByLastActivity()) {
|
||||
|
||||
CircleAvatar circleAvatar = CircleAvatar(
|
||||
foregroundImage: chatRoom.type == GetRoomResponseObjectConversationType.oneToOne ? Image.network("https://cloud.marianum-fulda.de/avatar/${chatRoom.name}/128").image : null,
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
foregroundColor: Colors.white,
|
||||
child: chatRoom.type == GetRoomResponseObjectConversationType.group ? const Icon(Icons.group) : const Icon(Icons.person),
|
||||
);
|
||||
CircleAvatar circleAvatar = CircleAvatar(
|
||||
foregroundImage: chatRoom.type == GetRoomResponseObjectConversationType.oneToOne ? Image.network("https://cloud.marianum-fulda.de/avatar/${chatRoom.name}/128").image : null,
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
foregroundColor: Colors.white,
|
||||
child: chatRoom.type == GetRoomResponseObjectConversationType.group ? const Icon(Icons.group) : const Icon(Icons.person),
|
||||
);
|
||||
|
||||
chats.add(ListTile(
|
||||
title: Text(chatRoom.displayName),
|
||||
subtitle: Text("${Jiffy.unixFromSecondsSinceEpoch(chatRoom.lastMessage.timestamp).fromNow()}: ${RichObjectStringProcessor.parseToString(chatRoom.lastMessage.message.replaceAll("\n", " "), chatRoom.lastMessage.messageParameters)}", overflow: TextOverflow.ellipsis),
|
||||
trailing: Visibility(
|
||||
visible: chatRoom.unreadMessages > 0,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(1),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).primaryColor,
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
constraints: const BoxConstraints(
|
||||
minWidth: 20,
|
||||
minHeight: 20,
|
||||
),
|
||||
child: Text(
|
||||
"${chatRoom.unreadMessages}",
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 15,
|
||||
chats.add(ListTile(
|
||||
title: Text(chatRoom.displayName),
|
||||
subtitle: Text("${Jiffy.unixFromSecondsSinceEpoch(chatRoom.lastMessage.timestamp).fromNow()}: ${RichObjectStringProcessor.parseToString(chatRoom.lastMessage.message.replaceAll("\n", " "), chatRoom.lastMessage.messageParameters)}", overflow: TextOverflow.ellipsis),
|
||||
trailing: Visibility(
|
||||
visible: chatRoom.unreadMessages > 0,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(1),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).primaryColor,
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
constraints: const BoxConstraints(
|
||||
minWidth: 20,
|
||||
minHeight: 20,
|
||||
),
|
||||
child: Text(
|
||||
"${chatRoom.unreadMessages}",
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 15,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
leading: circleAvatar,
|
||||
onTap: () async {
|
||||
Navigator.of(context).push(MaterialPageRoute(builder: (context) {
|
||||
return ChatView(
|
||||
room: chatRoom,
|
||||
selfId: username,
|
||||
avatar: circleAvatar,
|
||||
);
|
||||
}));
|
||||
},
|
||||
));
|
||||
}
|
||||
leading: circleAvatar,
|
||||
onTap: () async {
|
||||
Navigator.of(context).push(MaterialPageRoute(builder: (context) {
|
||||
return ChatView(
|
||||
room: chatRoom,
|
||||
selfId: username,
|
||||
avatar: circleAvatar,
|
||||
);
|
||||
}));
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
return RefreshIndicator(
|
||||
color: Theme.of(context).primaryColor,
|
||||
onRefresh: () {
|
||||
Provider.of<ChatListProps>(context, listen: false).run(renew: true);
|
||||
return Future.delayed(const Duration(seconds: 3));
|
||||
},
|
||||
child: ListView(children: chats),
|
||||
);
|
||||
},
|
||||
return RefreshIndicator(
|
||||
color: Theme.of(context).primaryColor,
|
||||
onRefresh: () {
|
||||
Provider.of<ChatListProps>(context, listen: false).run(renew: true);
|
||||
return Future.delayed(const Duration(seconds: 3));
|
||||
},
|
||||
child: ListView(children: chats),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user