opt mobile unread and autoSizeTextField

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages 2023-07-10 21:03:35 +08:00
parent 193426a3c1
commit 745f33a8c1
44 changed files with 160 additions and 46 deletions

View File

@ -2194,7 +2194,7 @@ Widget buildRemoteBlock({required Widget child, WhetherUseRemoteBlock? use}) {
}
Widget unreadMessageCountBuilder(RxInt? count,
{double? size, double? fontSize, double? marginLeft}) {
{double? size, double? fontSize}) {
return Obx(() => Offstage(
offstage: !((count?.value ?? 0) > 0),
child: Container(
@ -2209,5 +2209,18 @@ Widget unreadMessageCountBuilder(RxInt? count,
maxLines: 1,
style: TextStyle(color: Colors.white, fontSize: fontSize ?? 10)),
),
).marginOnly(left: marginLeft ?? 4)));
)));
}
Widget unreadTopRightBuilder(RxInt? count,
{Widget? icon, double? size, double? fontSize}) {
return Stack(
children: [
icon ?? Icon(Icons.chat),
Positioned(
top: 0,
right: 0,
child: unreadMessageCountBuilder(count, size: 12, fontSize: 8))
],
);
}

View File

@ -24,22 +24,14 @@ class ChatPage extends StatelessWidget implements PageShape {
final title = translate("Chat");
@override
final icon = Icon(Icons.chat);
final icon = unreadTopRightBuilder(gFFI.chatModel.mobileUnreadSum);
@override
final appBarActions = [
PopupMenuButton<MessageKey>(
tooltip: "",
icon: Stack(
children: [
Icon(Icons.group),
Positioned(
top: 0,
right: 0,
child: unreadMessageCountBuilder(gFFI.chatModel.mobileUnreadSum,
marginLeft: 0, size: 12, fontSize: 8))
],
),
icon: unreadTopRightBuilder(gFFI.chatModel.mobileUnreadSum,
icon: Icon(Icons.group)),
itemBuilder: (context) {
// only mobile need [appBarActions], just bind gFFI.chatModel
final chatModel = gFFI.chatModel;
@ -65,10 +57,12 @@ class ChatPage extends StatelessWidget implements PageShape {
width: 10,
height: 10,
decoration: BoxDecoration(
shape: BoxShape.circle, color: Colors.green),
shape: BoxShape.circle,
color: Color.fromARGB(255, 46, 205, 139)),
).marginSymmetric(horizontal: 2),
if (client != null)
unreadMessageCountBuilder(client.unreadChatMessageCount)
.marginOnly(left: 4)
],
),
value: key,
@ -88,7 +82,6 @@ class ChatPage extends StatelessWidget implements PageShape {
color: Theme.of(context).scaffoldBackgroundColor,
child: Consumer<ChatModel>(
builder: (context, chatModel, child) {
final currentUser = chatModel.currentUser;
final readOnly = type == ChatPageType.mobileMain &&
(chatModel.currentKey.connId == ChatModel.clientModeID ||
gFFI.serverModel.clients.every((e) =>
@ -177,28 +170,6 @@ class ChatPage extends StatelessWidget implements PageShape {
);
return SelectionArea(child: chat);
}),
desktopType == DesktopType.cm ||
type != ChatPageType.mobileMain ||
currentUser == null
? SizedBox.shrink()
: Padding(
padding: EdgeInsets.all(12),
child: Row(
children: [
Icon(
chatModel.currentKey.isOut
? Icons.call_made_rounded
: Icons.call_received_rounded,
color: MyTheme.accent),
Icon(Icons.account_circle, color: MyTheme.accent80),
SizedBox(width: 5),
Text(
"${currentUser.firstName} ${currentUser.id}",
style: TextStyle(color: MyTheme.accent),
),
],
),
),
],
).paddingOnly(bottom: 8);
},

View File

@ -205,7 +205,8 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
).paddingOnly(right: 5),
),
label,
unreadMessageCountBuilder(UnreadChatCountState.find(key)),
unreadMessageCountBuilder(UnreadChatCountState.find(key))
.marginOnly(left: 4),
],
);

View File

@ -165,7 +165,8 @@ class ConnectionManagerState extends State<ConnectionManager> {
message: key,
waitDuration: Duration(seconds: 1),
child: label),
unreadMessageCountBuilder(client?.unreadChatMessageCount),
unreadMessageCountBuilder(client?.unreadChatMessageCount)
.marginOnly(left: 4),
],
);
},

View File

@ -1,5 +1,6 @@
import 'dart:async';
import 'package:auto_size_text_field/auto_size_text_field.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hbb/common/formatter/id_formatter.dart';
import 'package:get/get.dart';
@ -131,7 +132,8 @@ class _ConnectionPageState extends State<ConnectionPage> {
Expanded(
child: Container(
padding: const EdgeInsets.only(left: 16, right: 16),
child: TextField(
child: AutoSizeTextField(
minFontSize: 18,
autocorrect: false,
enableSuggestions: false,
keyboardType: TextInputType.visiblePassword,

View File

@ -1,13 +1,14 @@
import 'package:flutter/material.dart';
import 'package:flutter_hbb/mobile/pages/server_page.dart';
import 'package:flutter_hbb/mobile/pages/settings_page.dart';
import 'package:get/get.dart';
import '../../common.dart';
import '../../common/widgets/chat_page.dart';
import 'connection_page.dart';
abstract class PageShape extends Widget {
final String title = "";
final Icon icon = Icon(null);
final Widget icon = Icon(null);
final List<Widget> appBarActions = [];
}
@ -63,7 +64,7 @@ class _HomePageState extends State<HomePage> {
// backgroundColor: MyTheme.grayBg,
appBar: AppBar(
centerTitle: true,
title: Text("RustDesk"),
title: appTitle(),
actions: _pages.elementAt(_selectedIndex).appBarActions,
),
bottomNavigationBar: BottomNavigationBar(
@ -81,15 +82,62 @@ class _HomePageState extends State<HomePage> {
if (index == 1 && _selectedIndex != index) {
gFFI.chatModel.hideChatIconOverlay();
gFFI.chatModel.hideChatWindowOverlay();
}
_selectedIndex = index;
gFFI.chatModel
.mobileClearClientUnread(gFFI.chatModel.currentKey.connId);
}
_selectedIndex = index;
}),
),
body: _pages.elementAt(_selectedIndex),
));
}
Widget appTitle() {
final currentUser = gFFI.chatModel.currentUser;
final currentKey = gFFI.chatModel.currentKey;
if (_selectedIndex == 1 &&
currentUser != null &&
currentKey.peerId.isNotEmpty) {
final connected =
gFFI.serverModel.clients.any((e) => e.id == currentKey.connId);
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Tooltip(
message: currentKey.isOut
? translate('outgoing connection')
: translate('incomming connection'),
child: Icon(
currentKey.isOut
? Icons.call_made_rounded
: Icons.call_received_rounded,
),
),
Expanded(
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"${currentUser.firstName} ${currentUser.id}",
),
if (connected)
Container(
width: 10,
height: 10,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Color.fromARGB(255, 133, 246, 199)),
).marginSymmetric(horizontal: 2),
],
),
),
),
],
);
}
return Text("RustDesk");
}
}
class WebHomePage extends StatelessWidget {

View File

@ -428,7 +428,8 @@ class ConnectionManager extends StatelessWidget {
bar.onTap!(1);
}
},
icon: const Icon(Icons.chat)))
icon: unreadTopRightBuilder(
client.unreadChatMessageCount)))
],
),
client.authorized

View File

@ -25,7 +25,7 @@ import 'model.dart';
class MessageKey {
final String peerId;
final int connId;
bool get isOut => connId != ChatModel.clientModeID;
bool get isOut => connId == ChatModel.clientModeID;
MessageKey(this.peerId, this.connId);

View File

@ -65,6 +65,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.0.0"
auto_size_text_field:
dependency: "direct main"
description:
name: auto_size_text_field
sha256: "8967129167193fefbb7a8707ade1bb71f9e52b9a5cf6da0132b7f6b7946c5a3f"
url: "https://pub.dev"
source: hosted
version: "2.2.1"
back_button_interceptor:
dependency: "direct main"
description:

View File

@ -96,6 +96,7 @@ dependencies:
percent_indicator: ^4.2.2
dropdown_button2: ^2.0.0
uuid: ^3.0.7
auto_size_text_field: ^2.2.1
dev_dependencies:
icons_launcher: ^2.0.4

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", "接受并提权"),
("accept_and_elevate_btn_tooltip", "接受连接并提升 UAC 权限"),
("clipboard_wait_response_timeout_tip", "等待拷贝响应超时"),
("incomming connection", "收到的连接"),
("outgoing connection", "发起的连接"),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", "Akzeptieren und Rechte erhöhen"),
("accept_and_elevate_btn_tooltip", "Akzeptieren Sie die Verbindung und erhöhen Sie die UAC-Berechtigungen."),
("clipboard_wait_response_timeout_tip", "Zeitüberschreitung beim Warten auf die Antwort der Kopie."),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", "Aceptar y Elevar"),
("accept_and_elevate_btn_tooltip", "Aceptar la conexión y elevar permisos UAC."),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", "بپذیرید و افزایش دهید"),
("accept_and_elevate_btn_tooltip", "را افزایش دهید UAC اتصال را بپذیرید و مجوزهای."),
("clipboard_wait_response_timeout_tip", "زمان انتظار برای مشخص شدن وضعیت کپی تمام شد."),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", "Accetta ed eleva"),
("accept_and_elevate_btn_tooltip", "Accetta la connessione ed eleva le autorizzazioni UAC."),
("clipboard_wait_response_timeout_tip", "Timeout attesa risposta della copia."),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", "Accepteren en Verheffen"),
("accept_and_elevate_btn_tooltip", "Accepteer de verbinding en verhoog de UAC-machtigingen."),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", "Akceptuj i Podnieś uprawnienia"),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", "Принять и повысить"),
("accept_and_elevate_btn_tooltip", "Разрешить подключение и повысить права UAC."),
("clipboard_wait_response_timeout_tip", "Время ожидания копирования буфера обмена, истекло"),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", ""),
("accept_and_elevate_btn_tooltip", ""),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", "收到的連接"),
("outgoing connection", "發起的連接"),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", "Погодитись та розширити права"),
("accept_and_elevate_btn_tooltip", "Погодити підключення та розширити дозволи UAC."),
("clipboard_wait_response_timeout_tip", "Вийшов час очікування копіювання."),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}

View File

@ -513,5 +513,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Accept and Elevate", "Chấp nhận và Cấp Quyền"),
("accept_and_elevate_btn_tooltip", "Chấp nhận kết nối và cấp các quyền UAC."),
("clipboard_wait_response_timeout_tip", ""),
("incomming connection", ""),
("outgoing connection", ""),
].iter().cloned().collect();
}