Skip to content

Commit d4793d3

Browse files
committed
优化桌面端视图
1 parent adfc8fe commit d4793d3

15 files changed

+555
-107
lines changed

lib/app/plateform_adapter/window/window_size_helper.dart

-18
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import 'dart:io';
2+
3+
import 'package:flutter/material.dart';
4+
import 'package:window_manager/window_manager.dart';
5+
6+
class WindowsAdapter {
7+
8+
static Future<void> setSize() async {
9+
if (Platform.isMacOS || Platform.isWindows || Platform.isLinux) {
10+
//仅对桌面端进行尺寸设置
11+
await windowManager.ensureInitialized();
12+
WindowOptions windowOptions = const WindowOptions(
13+
size: Size(900,600),
14+
minimumSize: Size(900,600),
15+
center: true,
16+
backgroundColor: Colors.transparent,
17+
skipTaskbar: false,
18+
titleBarStyle: TitleBarStyle.hidden,
19+
);
20+
windowManager.waitUntilReadyToShow(windowOptions, () async {
21+
// await windowManager.setAsFrameless();
22+
await windowManager.show();
23+
await windowManager.focus();
24+
});
25+
}
26+
}
27+
28+
}
29+
30+
31+
class DragToMoveAreaNoDouble extends StatelessWidget {
32+
final Widget child;
33+
34+
const DragToMoveAreaNoDouble({
35+
Key? key,
36+
required this.child,
37+
}) : super(key: key);
38+
39+
@override
40+
Widget build(BuildContext context) {
41+
return GestureDetector(
42+
behavior: HitTestBehavior.translucent,
43+
onPanStart: (details) {
44+
windowManager.startDragging();
45+
},
46+
child: child,
47+
);
48+
}
49+
}

lib/main.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:flutter/gestures.dart';
22
import 'package:flutter/material.dart';
3-
import 'package:flutter_unit/app/plateform_adapter/window/window_size_helper.dart';
43

4+
import 'app/plateform_adapter/window/windows_adapter.dart';
55
import 'app/views/navigation/bloc_wrapper.dart';
66
import 'app/views/navigation/flutter_unit.dart';
77

@@ -11,6 +11,6 @@ void main() {
1111
//滚动性能优化 1.22.0
1212
GestureBinding.instance.resamplingEnabled = true;
1313
runApp(const BlocWrapper(child: FlutterUnit()));
14-
WindowSizeHelper.setFixSize();
14+
WindowsAdapter.setSize();
1515
}
1616

lib/navigation/navigation/unit_desk_navigation.dart

+77-68
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import 'package:flutter_unit/painter_system/gallery_unit.dart';
1010
import 'package:flutter_unit/widget_system/views/widget_system_view.dart';
1111

1212
import 'package:url_launcher/url_launcher.dart';
13+
import 'package:window_manager/window_manager.dart';
1314

15+
import '../../app/plateform_adapter/window/windows_adapter.dart';
16+
import '../../widget_system/views/desk_ui/widget_panel/widget_panel.dart';
1417
import '../home_page/home_drawer.dart';
1518
import '../home_page/home_page.dart';
1619

@@ -53,10 +56,10 @@ class _UnitDeskNavigationState extends State<UnitDeskNavigation> {
5356
Widget build(BuildContext context) {
5457
return BlocBuilder<ColorChangeCubit, SelectTab>(
5558
builder: (_, state) => Scaffold(
56-
drawer: HomeDrawer(),
57-
endDrawer: HomeRightDrawer(),
59+
drawer: const HomeDrawer(),
60+
endDrawer: const HomeRightDrawer(),
5861
//右滑页
59-
floatingActionButton: _buildSearchButton(state.tabColor),
62+
// floatingActionButton: _buildSearchButton(state.tabColor),
6063
body: Row(
6164
children: [
6265
_buildLeftNav(),
@@ -66,8 +69,9 @@ class _UnitDeskNavigationState extends State<UnitDeskNavigation> {
6669
physics: const NeverScrollableScrollPhysics(),
6770
//使用PageView实现页面的切换
6871
controller: _controller,
69-
children: <Widget>[
70-
HomePage(),
72+
children: const <Widget>[
73+
// HomePage(),
74+
DeskWidgetPanel(),
7175
CollectPage(),
7276
GalleryUnit(),
7377
// GalleryPage(),
@@ -100,71 +104,76 @@ class _UnitDeskNavigationState extends State<UnitDeskNavigation> {
100104
}
101105

102106
Widget _buildLeftNav() {
103-
return Container(
104-
padding: EdgeInsets.only(top: 20),
105-
alignment: Alignment.topCenter,
106-
margin: EdgeInsets.only(right: 1),
107-
width: 120,
108-
decoration: BoxDecoration(color: Color(0xff2C3036), boxShadow: [
109-
BoxShadow(color: Colors.grey, offset: Offset(1, 0), blurRadius: 2)
110-
]),
111-
child: Column(
112-
children: [
113-
Wrap(
114-
direction: Axis.vertical,
115-
spacing: 10,
116-
crossAxisAlignment: WrapCrossAlignment.center,
117-
children: [
118-
CircleImage(
119-
image: AssetImage('assets/images/icon_head.webp'),
120-
size: 60,
121-
),
122-
Text(
123-
'张风捷特烈',
124-
style: TextStyle(color: Colors.white70),
125-
)
126-
],
127-
),
128-
buildIcons(),
129-
Divider(
130-
color: Colors.white,
131-
height: 1,
132-
endIndent: 20,
133-
),
107+
return DragToMoveAreaNoDouble(
108+
child: Container(
109+
padding: const EdgeInsets.only(top: 20),
110+
alignment: Alignment.topCenter,
111+
margin: const EdgeInsets.only(right: 1),
112+
width: 120,
113+
decoration: const BoxDecoration(color:
114+
Color(0xff2C3036),
115+
boxShadow: [
116+
BoxShadow(color: Colors.grey, offset: Offset(1, 0), blurRadius: 2)
117+
]
118+
),
119+
child: Column(
120+
children: [
121+
Wrap(
122+
direction: Axis.vertical,
123+
spacing: 10,
124+
crossAxisAlignment: WrapCrossAlignment.center,
125+
children: const [
126+
CircleImage(
127+
image: AssetImage('assets/images/icon_head.webp'),
128+
size: 60,
129+
),
130+
Text(
131+
'张风捷特烈',
132+
style: TextStyle(color: Colors.white70),
133+
)
134+
],
135+
),
136+
buildIcons(),
137+
const Divider(
138+
color: Colors.white,
139+
height: 1,
140+
endIndent: 20,
141+
),
134142
// SizedBox(height: 60,),
135-
Expanded(
136-
flex: 5,
137-
child: Center(
138-
child: RightNavBar(
139-
itemData: Cons.iconMap,
140-
onItemClick: _onTapNav,
141-
color: Theme.of(context).primaryColor,
143+
Expanded(
144+
flex: 5,
145+
child: Center(
146+
child: RightNavBar(
147+
itemData: Cons.iconMap,
148+
onItemClick: _onTapNav,
149+
color: Theme.of(context).primaryColor,
150+
),
142151
),
143152
),
144-
),
145153

146-
Expanded(
147-
child: Container(),
148-
flex: 1,
149-
),
150-
Divider(
151-
indent: 20,
152-
color: Colors.white,
153-
height: 1,
154-
),
155-
Builder(
156-
builder: (ctx) => FeedbackWidget(
157-
onPressed: () => Scaffold.of(ctx).openDrawer(),
158-
child: Padding(
159-
padding: const EdgeInsets.only(bottom: 20, top: 20),
160-
child: Icon(
161-
Icons.settings,
162-
color: Colors.white,
154+
Expanded(
155+
child: Container(),
156+
flex: 1,
157+
),
158+
const Divider(
159+
indent: 20,
160+
color: Colors.white,
161+
height: 1,
162+
),
163+
Builder(
164+
builder: (ctx) => FeedbackWidget(
165+
onPressed: () => Scaffold.of(ctx).openDrawer(),
166+
child: const Padding(
167+
padding: EdgeInsets.only(bottom: 20, top: 20),
168+
child: Icon(
169+
Icons.settings,
170+
color: Colors.white,
171+
),
163172
),
164173
),
165174
),
166-
),
167-
],
175+
],
176+
),
168177
),
169178
);
170179
}
@@ -177,23 +186,23 @@ class _UnitDeskNavigationState extends State<UnitDeskNavigation> {
177186
children: [
178187
FeedbackWidget(
179188
onPressed: () => _launchURL("http://blog.toly1994.com"),
180-
child: Icon(
189+
child: const Icon(
181190
TolyIcon.icon_item,
182191
color: Colors.white,
183192
),
184193
),
185194
FeedbackWidget(
186195
onPressed: () =>
187196
_launchURL("https://github.com/toly1994328/FlutterUnit"),
188-
child: Icon(
197+
child: const Icon(
189198
TolyIcon.icon_github,
190199
color: Colors.white,
191200
),
192201
),
193202
FeedbackWidget(
194203
onPressed: () =>
195204
_launchURL("https://juejin.im/user/5b42c0656fb9a04fe727eb37"),
196-
child: Icon(
205+
child: const Icon(
197206
TolyIcon.icon_juejin,
198207
color: Colors.white,
199208
),
@@ -250,14 +259,14 @@ class _RightNavBarState extends State<RightNavBar> {
250259
onTap: () => _tapTab(i),
251260
child: Container(
252261
alignment: Alignment.topLeft,
253-
margin: EdgeInsets.only(top: 10),
262+
margin: const EdgeInsets.only(top: 10),
254263
width: widget.itemSize.width,
255264
child: UnconstrainedBox(
256265
child: Container(
257266
alignment: Alignment.center,
258267
decoration: BoxDecoration(
259268
color: active ? widget.color : Colors.white.withAlpha(33),
260-
borderRadius: BorderRadius.only(
269+
borderRadius: const BorderRadius.only(
261270
topRight: Radius.circular(20),
262271
bottomRight: Radius.circular(20))),
263272
width: active
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import 'package:flutter/material.dart';
2+
3+
class DeskSearchBar extends StatelessWidget {
4+
final ValueChanged<String>? onChanged;
5+
6+
7+
const DeskSearchBar({Key? key,this.onChanged}) : super(key: key);
8+
9+
@override
10+
Widget build(BuildContext context) {
11+
return TextField(
12+
// controller: _ctrl,
13+
onChanged: onChanged,
14+
style: const TextStyle(fontSize: 12),
15+
maxLines: 1,
16+
decoration: const InputDecoration(
17+
filled: true,
18+
hoverColor: Colors.transparent,
19+
contentPadding: EdgeInsets.only(top: 0),
20+
fillColor: Color(0xffF1F2F3),
21+
prefixIcon: Icon(Icons.search, size: 18,color: Colors.grey,),
22+
border: UnderlineInputBorder(
23+
borderSide: BorderSide.none,
24+
borderRadius: BorderRadius.all(Radius.circular(8)),
25+
),
26+
hintText: "输入组件名称",
27+
hintStyle: TextStyle(fontSize: 12,color: Colors.grey)),
28+
);
29+
}
30+
}

0 commit comments

Comments
 (0)