change chat menu icon, and me->Me

This commit is contained in:
rustdesk 2022-04-05 00:51:47 +08:00
parent c434a9f789
commit 35e16e2299
3 changed files with 29 additions and 29 deletions

View File

@ -12,8 +12,8 @@ class ChatModel with ChangeNotifier {
final Map<int, List<ChatMessage>> _messages = Map()..[clientModeID] = [];
final ChatUser me = ChatUser(
uid:"",
name: "me",
uid: "",
name: "Me",
);
final _scroller = ScrollController();
@ -29,15 +29,15 @@ class ChatModel with ChangeNotifier {
ChatUser get currentUser =>
FFI.serverModel.clients[_currentID]?.chatUser ?? me;
changeCurrentID(int id){
if(_messages.containsKey(id)){
changeCurrentID(int id) {
if (_messages.containsKey(id)) {
_currentID = id;
notifyListeners();
} else {
final chatUser = FFI.serverModel.clients[id]?.chatUser;
if(chatUser == null){
return debugPrint("Failed to changeCurrentID,remote user doesn't exist");
if (chatUser == null) {
return debugPrint(
"Failed to changeCurrentID,remote user doesn't exist");
}
_messages[id] = [];
_currentID = id;
@ -51,32 +51,29 @@ class ChatModel with ChangeNotifier {
showChatIconOverlay();
}
late final chatUser;
if(id == clientModeID){
if (id == clientModeID) {
chatUser = ChatUser(
name: FFI.ffiModel.pi.username,
uid: FFI.getId(),
);
}else{
} else {
chatUser = FFI.serverModel.clients[id]?.chatUser;
}
if(chatUser == null){
if (chatUser == null) {
return debugPrint("Failed to receive msg,user doesn't exist");
}
if(!_messages.containsKey(id)){
if (!_messages.containsKey(id)) {
_messages[id] = [];
}
_messages[id]!.add(ChatMessage(
text: text,
user: chatUser));
_messages[id]!.add(ChatMessage(text: text, user: chatUser));
_currentID = id;
notifyListeners();
scrollToBottom();
}
scrollToBottom(){
scrollToBottom() {
Future.delayed(Duration(milliseconds: 500), () {
_scroller.animateTo(
_scroller.position.maxScrollExtent,
_scroller.animateTo(_scroller.position.maxScrollExtent,
duration: Duration(milliseconds: 200),
curve: Curves.fastLinearToSlowEaseIn);
});

View File

@ -22,7 +22,7 @@ class ChatPage extends StatelessWidget implements PageShape {
@override
final appBarActions = [
PopupMenuButton<int>(
icon: Icon(Icons.more_vert),
icon: Icon(Icons.group),
itemBuilder: (context) {
final chatModel = FFI.chatModel;
final serverModel = FFI.serverModel;
@ -66,16 +66,18 @@ class ChatPage extends StatelessWidget implements PageShape {
chatModel.currentID == ChatModel.clientModeID
? SizedBox.shrink()
: Padding(
padding: EdgeInsets.all(10),
child: Row(
children: [
Icon(Icons.account_circle,
color: MyTheme.accent80),
SizedBox(width: 5),
Text(
"${currentUser.name ?? ""} ${currentUser.uid ?? ""}",style: TextStyle(color: MyTheme.accent50),),
],
)),
padding: EdgeInsets.all(12),
child: Row(
children: [
Icon(Icons.account_circle,
color: MyTheme.accent80),
SizedBox(width: 5),
Text(
"${currentUser.name ?? ""} ${currentUser.uid ?? ""}",
style: TextStyle(color: MyTheme.accent50),
),
],
)),
],
);
})));

View File

@ -32,9 +32,10 @@ class _SettingsState extends State<SettingsPage> {
Provider.of<FfiModel>(context);
final username = getUsername();
return SettingsList(
contentPadding: EdgeInsets.symmetric(horizontal: 12),
sections: [
SettingsSection(
title: Text(""),
title: Text(translate("Account")),
tiles: [
SettingsTile.navigation(
title: Text(username == null