Merge pull request #1332 from 21pages/style

optimize ui style
This commit is contained in:
RustDesk 2022-08-23 09:55:43 +08:00 committed by GitHub
commit e4cae26dd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 218 additions and 160 deletions

View File

@ -59,6 +59,7 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
required this.text, required this.text,
required this.lightText, required this.lightText,
required this.lighterText, required this.lighterText,
required this.placeholder,
required this.border, required this.border,
}); });
@ -67,6 +68,7 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
final Color? text; final Color? text;
final Color? lightText; final Color? lightText;
final Color? lighterText; final Color? lighterText;
final Color? placeholder;
final Color? border; final Color? border;
static const light = ColorThemeExtension( static const light = ColorThemeExtension(
@ -75,6 +77,7 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
text: Color(0xFF222222), text: Color(0xFF222222),
lightText: Color(0xFF666666), lightText: Color(0xFF666666),
lighterText: Color(0xFF888888), lighterText: Color(0xFF888888),
placeholder: Color(0xFFAAAAAA),
border: Color(0xFFCCCCCC), border: Color(0xFFCCCCCC),
); );
@ -84,6 +87,7 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
text: Color(0xFFFFFFFF), text: Color(0xFFFFFFFF),
lightText: Color(0xFF999999), lightText: Color(0xFF999999),
lighterText: Color(0xFF777777), lighterText: Color(0xFF777777),
placeholder: Color(0xFF555555),
border: Color(0xFF555555), border: Color(0xFF555555),
); );
@ -94,6 +98,7 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
Color? text, Color? text,
Color? lightText, Color? lightText,
Color? lighterText, Color? lighterText,
Color? placeholder,
Color? border}) { Color? border}) {
return ColorThemeExtension( return ColorThemeExtension(
bg: bg ?? this.bg, bg: bg ?? this.bg,
@ -101,6 +106,7 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
text: text ?? this.text, text: text ?? this.text,
lightText: lightText ?? this.lightText, lightText: lightText ?? this.lightText,
lighterText: lighterText ?? this.lighterText, lighterText: lighterText ?? this.lighterText,
placeholder: placeholder ?? this.placeholder,
border: border ?? this.border, border: border ?? this.border,
); );
} }
@ -117,6 +123,7 @@ class ColorThemeExtension extends ThemeExtension<ColorThemeExtension> {
text: Color.lerp(text, other.text, t), text: Color.lerp(text, other.text, t),
lightText: Color.lerp(lightText, other.lightText, t), lightText: Color.lerp(lightText, other.lightText, t),
lighterText: Color.lerp(lighterText, other.lighterText, t), lighterText: Color.lerp(lighterText, other.lighterText, t),
placeholder: Color.lerp(placeholder, other.placeholder, t),
border: Color.lerp(border, other.border, t), border: Color.lerp(border, other.border, t),
); );
} }
@ -136,6 +143,8 @@ class MyTheme {
static const Color darkGray = Color(0xFFB9BABC); static const Color darkGray = Color(0xFFB9BABC);
static const Color cmIdColor = Color(0xFF21790B); static const Color cmIdColor = Color(0xFF21790B);
static const Color dark = Colors.black87; static const Color dark = Colors.black87;
static const Color button = Color(0xFF2C8CFF);
static const Color hoverBorder = Color(0xFF999999);
static ThemeData lightTheme = ThemeData( static ThemeData lightTheme = ThemeData(
brightness: Brightness.light, brightness: Brightness.light,
@ -144,7 +153,8 @@ class MyTheme {
tabBarTheme: TabBarTheme( tabBarTheme: TabBarTheme(
labelColor: Colors.black87, labelColor: Colors.black87,
), ),
// backgroundColor: Color(0xFFFFFFFF), splashColor: Colors.transparent,
highlightColor: Colors.transparent,
).copyWith( ).copyWith(
extensions: <ThemeExtension<dynamic>>[ extensions: <ThemeExtension<dynamic>>[
ColorThemeExtension.light, ColorThemeExtension.light,
@ -157,7 +167,8 @@ class MyTheme {
tabBarTheme: TabBarTheme( tabBarTheme: TabBarTheme(
labelColor: Colors.white70, labelColor: Colors.white70,
), ),
// backgroundColor: Color(0xFF252525) splashColor: Colors.transparent,
highlightColor: Colors.transparent,
).copyWith( ).copyWith(
extensions: <ThemeExtension<dynamic>>[ extensions: <ThemeExtension<dynamic>>[
ColorThemeExtension.dark, ColorThemeExtension.dark,

View File

@ -65,12 +65,14 @@ class _ConnectionPageState extends State<ConnectionPage> {
getUpdateUI(), getUpdateUI(),
Row( Row(
children: [ children: [
getSearchBarUI(), getSearchBarUI(context),
], ],
).marginOnly(top: 16.0, left: 16.0), ).marginOnly(top: 22, left: 22),
SizedBox(height: 12), SizedBox(height: 12),
Divider( Divider(
thickness: 1, thickness: 1,
indent: 22,
endIndent: 22,
), ),
Expanded( Expanded(
// TODO: move all tab info into _PeerTabbedPage // TODO: move all tab info into _PeerTabbedPage
@ -123,7 +125,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
} }
}), }),
], ],
)), ).marginSymmetric(horizontal: 6)),
Divider(), Divider(),
SizedBox(height: 50, child: Obx(() => buildStatus())) SizedBox(height: 50, child: Obx(() => buildStatus()))
.paddingSymmetric(horizontal: 12.0) .paddingSymmetric(horizontal: 12.0)
@ -178,12 +180,16 @@ class _ConnectionPageState extends State<ConnectionPage> {
/// UI for the search bar. /// UI for the search bar.
/// Search for a peer and connect to it if the id exists. /// Search for a peer and connect to it if the id exists.
Widget getSearchBarUI() { Widget getSearchBarUI(BuildContext context) {
RxBool ftHover = false.obs;
RxBool ftPressed = false.obs;
RxBool connHover = false.obs;
RxBool connPressed = false.obs;
var w = Container( var w = Container(
width: 500, width: 320 + 20 * 2,
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 24), padding: EdgeInsets.only(left: 20, right: 20, bottom: 22, top: 30),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isDarkTheme() ? null : MyTheme.white, color: MyTheme.color(context).bg,
borderRadius: const BorderRadius.all(Radius.circular(13)), borderRadius: const BorderRadius.all(Radius.circular(13)),
), ),
child: Ink( child: Ink(
@ -197,17 +203,12 @@ class _ConnectionPageState extends State<ConnectionPage> {
autocorrect: false, autocorrect: false,
enableSuggestions: false, enableSuggestions: false,
keyboardType: TextInputType.visiblePassword, keyboardType: TextInputType.visiblePassword,
// keyboardType: TextInputType.number,
style: TextStyle( style: TextStyle(
fontFamily: 'WorkSans', fontFamily: 'WorkSans',
fontWeight: FontWeight.bold, fontSize: 22,
fontSize: 30,
// color: MyTheme.idColor,
), ),
decoration: InputDecoration( decoration: InputDecoration(
labelText: translate('Control Remote Desktop'), labelText: translate('Control Remote Desktop'),
// hintText: 'Enter your remote ID',
// border: InputBorder.,
border: border:
OutlineInputBorder(borderRadius: BorderRadius.zero), OutlineInputBorder(borderRadius: BorderRadius.zero),
helperStyle: TextStyle( helperStyle: TextStyle(
@ -215,7 +216,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
fontSize: 16, fontSize: 16,
), ),
labelStyle: TextStyle( labelStyle: TextStyle(
fontWeight: FontWeight.w600, fontWeight: FontWeight.w500,
fontSize: 26, fontSize: 26,
letterSpacing: 0.2, letterSpacing: 0.2,
), ),
@ -230,41 +231,83 @@ class _ConnectionPageState extends State<ConnectionPage> {
], ],
), ),
Padding( Padding(
padding: const EdgeInsets.only(top: 16.0), padding: const EdgeInsets.only(top: 13.0),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
OutlinedButton( Obx(() => InkWell(
onPressed: () { onTapDown: (_) => ftPressed.value = true,
onTapUp: (_) => ftPressed.value = false,
onTapCancel: () => ftPressed.value = false,
onHover: (value) => ftHover.value = value,
onTap: () {
onConnect(isFileTransfer: true); onConnect(isFileTransfer: true);
}, },
child: Padding( child: Container(
padding: const EdgeInsets.symmetric( height: 24,
vertical: 8.0, horizontal: 8.0), width: 72,
alignment: Alignment.center,
decoration: BoxDecoration(
color: ftPressed.value
? MyTheme.accent
: Colors.transparent,
border: Border.all(
color: ftPressed.value
? MyTheme.accent
: ftHover.value
? MyTheme.hoverBorder
: MyTheme.border,
),
borderRadius: BorderRadius.circular(5),
),
child: Text( child: Text(
translate( translate(
"Transfer File", "Transfer File",
), ),
style: TextStyle(
fontSize: 12,
color: ftPressed.value
? MyTheme.color(context).bg
: MyTheme.color(context).text),
), ),
), ),
), )),
SizedBox( SizedBox(
width: 30, width: 17,
), ),
OutlinedButton( Obx(
onPressed: onConnect, () => InkWell(
child: Padding( onTapDown: (_) => connPressed.value = true,
padding: const EdgeInsets.symmetric( onTapUp: (_) => connPressed.value = false,
vertical: 8.0, horizontal: 16.0), onTapCancel: () => connPressed.value = false,
onHover: (value) => connHover.value = value,
onTap: onConnect,
child: Container(
height: 24,
width: 65,
decoration: BoxDecoration(
color: connPressed.value
? MyTheme.accent
: MyTheme.button,
border: Border.all(
color: connPressed.value
? MyTheme.accent
: connHover.value
? MyTheme.hoverBorder
: MyTheme.button,
),
borderRadius: BorderRadius.circular(5),
),
child: Center(
child: Text( child: Text(
translate( translate(
"Connection", "Connection",
), ),
style: TextStyle(color: MyTheme.white), style: TextStyle(
fontSize: 12, color: MyTheme.color(context).bg),
),
), ),
), ),
style: OutlinedButton.styleFrom(
backgroundColor: Colors.blueAccent,
), ),
), ),
], ],
@ -920,6 +963,7 @@ class _PeerTabbedPage extends StatefulWidget {
class _PeerTabbedPageState extends State<_PeerTabbedPage> class _PeerTabbedPageState extends State<_PeerTabbedPage>
with SingleTickerProviderStateMixin { with SingleTickerProviderStateMixin {
late TabController _tabController; late TabController _tabController;
RxInt _tabIndex = 0.obs;
@override @override
void initState() { void initState() {
@ -932,6 +976,7 @@ class _PeerTabbedPageState extends State<_PeerTabbedPage>
// hard code for now // hard code for now
void _handleTabSelection() { void _handleTabSelection() {
if (_tabController.indexIsChanging) { if (_tabController.indexIsChanging) {
_tabIndex.value = _tabController.index;
switch (_tabController.index) { switch (_tabController.index) {
case 0: case 0:
bind.mainLoadRecentPeers(); bind.mainLoadRecentPeers();
@ -969,19 +1014,37 @@ class _PeerTabbedPageState extends State<_PeerTabbedPage>
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
_createTabBar(), _createTabBar(context),
_createTabBarView(), _createTabBarView(),
], ],
); );
} }
Widget _createTabBar() { Widget _createTabBar(BuildContext context) {
return TabBar( return TabBar(
isScrollable: true, isScrollable: true,
indicatorSize: TabBarIndicatorSize.label, indicatorSize: TabBarIndicatorSize.label,
indicatorColor: Colors.transparent,
indicatorWeight: 0.1,
controller: _tabController, controller: _tabController,
tabs: super.widget.tabs.map((t) { labelPadding: EdgeInsets.zero,
return Tab(child: Text(t)); padding: EdgeInsets.only(left: 16),
tabs: super.widget.tabs.asMap().entries.map((t) {
return Obx(() => Container(
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 6),
decoration: BoxDecoration(
color:
_tabIndex.value == t.key ? MyTheme.color(context).bg : null,
borderRadius: BorderRadius.circular(2),
),
child: Text(
t.value,
style: TextStyle(
height: 1,
color: _tabIndex.value == t.key
? MyTheme.color(context).text
: MyTheme.color(context).lightText),
)));
}).toList()); }).toList());
} }

View File

@ -76,7 +76,11 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SubWindowDragToResizeArea( return SubWindowDragToResizeArea(
windowId: windowId(), windowId: windowId(),
child: Container(
decoration: BoxDecoration(
border: Border.all(color: MyTheme.color(context).border!)),
child: Scaffold( child: Scaffold(
backgroundColor: MyTheme.color(context).bg,
body: Column( body: Column(
children: [ children: [
Obx(() => Visibility( Obx(() => Visibility(
@ -106,6 +110,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
], ],
), ),
), ),
),
); );
} }

View File

@ -90,7 +90,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
buildIDBoard(BuildContext context) { buildIDBoard(BuildContext context) {
final model = gFFI.serverModel; final model = gFFI.serverModel;
return Container( return Container(
margin: EdgeInsets.symmetric(horizontal: 16), margin: EdgeInsets.only(left: 20, right: 16),
height: 52, height: 52,
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.baseline, crossAxisAlignment: CrossAxisAlignment.baseline,
@ -133,11 +133,12 @@ class _DesktopHomePageState extends State<DesktopHomePage>
readOnly: true, readOnly: true,
decoration: InputDecoration( decoration: InputDecoration(
border: InputBorder.none, border: InputBorder.none,
contentPadding: EdgeInsets.only(bottom: 8),
), ),
style: TextStyle( style: TextStyle(
fontSize: 22, fontSize: 22,
), ),
).marginOnly(bottom: 5), ),
), ),
) )
], ],
@ -240,7 +241,8 @@ class _DesktopHomePageState extends State<DesktopHomePage>
child: Obx( child: Obx(
() => Container( () => Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(90), // borderRadius: BorderRadius.circular(10),
shape: BoxShape.circle,
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: hover.value color: hover.value
@ -268,7 +270,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
final model = gFFI.serverModel; final model = gFFI.serverModel;
RxBool refreshHover = false.obs; RxBool refreshHover = false.obs;
return Container( return Container(
margin: EdgeInsets.symmetric(vertical: 12, horizontal: 16.0), margin: EdgeInsets.only(left: 20.0, right: 16, top: 13, bottom: 13),
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.baseline, crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic, textBaseline: TextBaseline.alphabetic,
@ -306,6 +308,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
readOnly: true, readOnly: true,
decoration: InputDecoration( decoration: InputDecoration(
border: InputBorder.none, border: InputBorder.none,
contentPadding: EdgeInsets.only(bottom: 8),
), ),
style: TextStyle(fontSize: 15), style: TextStyle(fontSize: 15),
), ),
@ -319,7 +322,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
? MyTheme.color(context).text ? MyTheme.color(context).text
: Color(0xFFDDDDDD), : Color(0xFFDDDDDD),
size: 22, size: 22,
).marginOnly(right: 5), ).marginOnly(right: 10, bottom: 8),
), ),
onTap: () => bind.mainUpdateTemporaryPassword(), onTap: () => bind.mainUpdateTemporaryPassword(),
onHover: (value) => refreshHover.value = value, onHover: (value) => refreshHover.value = value,
@ -337,7 +340,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
} }
}) })
], ],
).marginOnly(bottom: 20), ),
], ],
), ),
), ),
@ -426,12 +429,14 @@ class _DesktopHomePageState extends State<DesktopHomePage>
size: 22, size: 22,
color: editHover.value color: editHover.value
? MyTheme.color(context).text ? MyTheme.color(context).text
: Color(0xFFDDDDDD)))); : Color(0xFFDDDDDD))
.marginOnly(bottom: 8)));
} }
buildTip(BuildContext context) { buildTip(BuildContext context) {
return Padding( return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), padding:
const EdgeInsets.only(left: 20.0, right: 16, top: 16.0, bottom: 14),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@ -441,53 +446,21 @@ class _DesktopHomePageState extends State<DesktopHomePage>
style: TextStyle(fontWeight: FontWeight.normal, fontSize: 19), style: TextStyle(fontWeight: FontWeight.normal, fontSize: 19),
), ),
SizedBox( SizedBox(
height: 8.0, height: 10.0,
), ),
Text( Text(
translate("desk_tip"), translate("desk_tip"),
overflow: TextOverflow.clip, overflow: TextOverflow.clip,
style: TextStyle( style: TextStyle(
fontSize: 12, color: MyTheme.color(context).lighterText), fontSize: 12,
color: MyTheme.color(context).lighterText,
height: 1.25),
) )
], ],
), ),
); );
} }
buildControlPanel(BuildContext context) {
return Container(
width: 320,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10), color: MyTheme.white),
padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
translate("Control Remote Desktop"),
style: TextStyle(fontWeight: FontWeight.normal, fontSize: 19),
),
Form(
child: Column(
children: [
TextFormField(
controller: TextEditingController(),
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r"[0-9]"))
],
style: TextStyle(fontSize: 22, fontWeight: FontWeight.w400),
)
],
))
],
),
);
}
buildRecentSession(BuildContext context) {
return Center(child: Text("waiting implementation"));
}
@override @override
void onTrayMenuItemClick(MenuItem menuItem) { void onTrayMenuItemClick(MenuItem menuItem) {
print("click ${menuItem.key}"); print("click ${menuItem.key}");

View File

@ -72,7 +72,11 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SubWindowDragToResizeArea( return SubWindowDragToResizeArea(
windowId: windowId(), windowId: windowId(),
child: Container(
decoration: BoxDecoration(
border: Border.all(color: MyTheme.color(context).border!)),
child: Scaffold( child: Scaffold(
backgroundColor: MyTheme.color(context).bg,
body: Column( body: Column(
children: [ children: [
DesktopTabBar( DesktopTabBar(
@ -96,6 +100,7 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
], ],
), ),
), ),
),
); );
} }

View File

@ -33,8 +33,13 @@ class _DesktopServerPageState extends State<DesktopServerPage>
ChangeNotifierProvider.value(value: gFFI.chatModel), ChangeNotifierProvider.value(value: gFFI.chatModel),
], ],
child: Consumer<ServerModel>( child: Consumer<ServerModel>(
builder: (context, serverModel, child) => Material( builder: (context, serverModel, child) => Container(
child: Center( decoration: BoxDecoration(
border:
Border.all(color: MyTheme.color(context).border!)),
child: Scaffold(
backgroundColor: MyTheme.color(context).bg,
body: Center(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
@ -43,6 +48,7 @@ class _DesktopServerPageState extends State<DesktopServerPage>
], ],
), ),
), ),
),
))); )));
} }

View File

@ -249,6 +249,7 @@ class WindowActionPanel extends StatelessWidget {
}, },
is_close: false, is_close: false,
)), )),
// TODO: drag makes window restore
Offstage( Offstage(
offstage: !showMaximize, offstage: !showMaximize,
child: FutureBuilder(builder: (context, snapshot) { child: FutureBuilder(builder: (context, snapshot) {
@ -273,22 +274,16 @@ class WindowActionPanel extends StatelessWidget {
if (is_maximized.value) { if (is_maximized.value) {
windowManager.unmaximize(); windowManager.unmaximize();
} else { } else {
WindowController.fromWindowId(windowId!).minimize(); windowManager.maximize();
} }
} else { } else {
// TODO: subwindow is maximized but first query result is not maximized.
final wc = WindowController.fromWindowId(windowId!); final wc = WindowController.fromWindowId(windowId!);
if (is_maximized.value) { if (is_maximized.value) {
wc.unmaximize(); wc.unmaximize();
} else {
final wc = WindowController.fromWindowId(windowId!);
wc.isMaximized().then((maximized) {
if (maximized) {
wc.unmaximize();
} else { } else {
wc.maximize(); wc.maximize();
} }
});
}
} }
is_maximized.value = !is_maximized.value; is_maximized.value = !is_maximized.value;
}, },