change chat menu icon, and me->Me
This commit is contained in:
parent
c434a9f789
commit
35e16e2299
@ -12,8 +12,8 @@ class ChatModel with ChangeNotifier {
|
|||||||
final Map<int, List<ChatMessage>> _messages = Map()..[clientModeID] = [];
|
final Map<int, List<ChatMessage>> _messages = Map()..[clientModeID] = [];
|
||||||
|
|
||||||
final ChatUser me = ChatUser(
|
final ChatUser me = ChatUser(
|
||||||
uid:"",
|
uid: "",
|
||||||
name: "me",
|
name: "Me",
|
||||||
);
|
);
|
||||||
|
|
||||||
final _scroller = ScrollController();
|
final _scroller = ScrollController();
|
||||||
@ -29,15 +29,15 @@ class ChatModel with ChangeNotifier {
|
|||||||
ChatUser get currentUser =>
|
ChatUser get currentUser =>
|
||||||
FFI.serverModel.clients[_currentID]?.chatUser ?? me;
|
FFI.serverModel.clients[_currentID]?.chatUser ?? me;
|
||||||
|
|
||||||
|
changeCurrentID(int id) {
|
||||||
changeCurrentID(int id){
|
if (_messages.containsKey(id)) {
|
||||||
if(_messages.containsKey(id)){
|
|
||||||
_currentID = id;
|
_currentID = id;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
} else {
|
} else {
|
||||||
final chatUser = FFI.serverModel.clients[id]?.chatUser;
|
final chatUser = FFI.serverModel.clients[id]?.chatUser;
|
||||||
if(chatUser == null){
|
if (chatUser == null) {
|
||||||
return debugPrint("Failed to changeCurrentID,remote user doesn't exist");
|
return debugPrint(
|
||||||
|
"Failed to changeCurrentID,remote user doesn't exist");
|
||||||
}
|
}
|
||||||
_messages[id] = [];
|
_messages[id] = [];
|
||||||
_currentID = id;
|
_currentID = id;
|
||||||
@ -51,32 +51,29 @@ class ChatModel with ChangeNotifier {
|
|||||||
showChatIconOverlay();
|
showChatIconOverlay();
|
||||||
}
|
}
|
||||||
late final chatUser;
|
late final chatUser;
|
||||||
if(id == clientModeID){
|
if (id == clientModeID) {
|
||||||
chatUser = ChatUser(
|
chatUser = ChatUser(
|
||||||
name: FFI.ffiModel.pi.username,
|
name: FFI.ffiModel.pi.username,
|
||||||
uid: FFI.getId(),
|
uid: FFI.getId(),
|
||||||
);
|
);
|
||||||
}else{
|
} else {
|
||||||
chatUser = FFI.serverModel.clients[id]?.chatUser;
|
chatUser = FFI.serverModel.clients[id]?.chatUser;
|
||||||
}
|
}
|
||||||
if(chatUser == null){
|
if (chatUser == null) {
|
||||||
return debugPrint("Failed to receive msg,user doesn't exist");
|
return debugPrint("Failed to receive msg,user doesn't exist");
|
||||||
}
|
}
|
||||||
if(!_messages.containsKey(id)){
|
if (!_messages.containsKey(id)) {
|
||||||
_messages[id] = [];
|
_messages[id] = [];
|
||||||
}
|
}
|
||||||
_messages[id]!.add(ChatMessage(
|
_messages[id]!.add(ChatMessage(text: text, user: chatUser));
|
||||||
text: text,
|
|
||||||
user: chatUser));
|
|
||||||
_currentID = id;
|
_currentID = id;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollToBottom(){
|
scrollToBottom() {
|
||||||
Future.delayed(Duration(milliseconds: 500), () {
|
Future.delayed(Duration(milliseconds: 500), () {
|
||||||
_scroller.animateTo(
|
_scroller.animateTo(_scroller.position.maxScrollExtent,
|
||||||
_scroller.position.maxScrollExtent,
|
|
||||||
duration: Duration(milliseconds: 200),
|
duration: Duration(milliseconds: 200),
|
||||||
curve: Curves.fastLinearToSlowEaseIn);
|
curve: Curves.fastLinearToSlowEaseIn);
|
||||||
});
|
});
|
||||||
|
@ -22,7 +22,7 @@ class ChatPage extends StatelessWidget implements PageShape {
|
|||||||
@override
|
@override
|
||||||
final appBarActions = [
|
final appBarActions = [
|
||||||
PopupMenuButton<int>(
|
PopupMenuButton<int>(
|
||||||
icon: Icon(Icons.more_vert),
|
icon: Icon(Icons.group),
|
||||||
itemBuilder: (context) {
|
itemBuilder: (context) {
|
||||||
final chatModel = FFI.chatModel;
|
final chatModel = FFI.chatModel;
|
||||||
final serverModel = FFI.serverModel;
|
final serverModel = FFI.serverModel;
|
||||||
@ -66,16 +66,18 @@ class ChatPage extends StatelessWidget implements PageShape {
|
|||||||
chatModel.currentID == ChatModel.clientModeID
|
chatModel.currentID == ChatModel.clientModeID
|
||||||
? SizedBox.shrink()
|
? SizedBox.shrink()
|
||||||
: Padding(
|
: Padding(
|
||||||
padding: EdgeInsets.all(10),
|
padding: EdgeInsets.all(12),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.account_circle,
|
Icon(Icons.account_circle,
|
||||||
color: MyTheme.accent80),
|
color: MyTheme.accent80),
|
||||||
SizedBox(width: 5),
|
SizedBox(width: 5),
|
||||||
Text(
|
Text(
|
||||||
"${currentUser.name ?? ""} ${currentUser.uid ?? ""}",style: TextStyle(color: MyTheme.accent50),),
|
"${currentUser.name ?? ""} ${currentUser.uid ?? ""}",
|
||||||
],
|
style: TextStyle(color: MyTheme.accent50),
|
||||||
)),
|
),
|
||||||
|
],
|
||||||
|
)),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
})));
|
})));
|
||||||
|
@ -32,9 +32,10 @@ class _SettingsState extends State<SettingsPage> {
|
|||||||
Provider.of<FfiModel>(context);
|
Provider.of<FfiModel>(context);
|
||||||
final username = getUsername();
|
final username = getUsername();
|
||||||
return SettingsList(
|
return SettingsList(
|
||||||
|
contentPadding: EdgeInsets.symmetric(horizontal: 12),
|
||||||
sections: [
|
sections: [
|
||||||
SettingsSection(
|
SettingsSection(
|
||||||
title: Text(""),
|
title: Text(translate("Account")),
|
||||||
tiles: [
|
tiles: [
|
||||||
SettingsTile.navigation(
|
SettingsTile.navigation(
|
||||||
title: Text(username == null
|
title: Text(username == null
|
||||||
|
Loading…
x
Reference in New Issue
Block a user