Skip to content

Commit 65159bb

Browse files
committed
Switch to ZenitUI
1 parent b5d3bfe commit 65159bb

4 files changed

Lines changed: 167 additions & 102 deletions

File tree

lib/main.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1010
See the License for the specific language governing permissions and
1111
limitations under the License.
1212
*/
13-
import 'package:fluent_ui/fluent_ui.dart';
1413
import 'package:terminal/views/terminal_frame.dart';
1514
import 'package:terminal/views/terminal_settings.dart';
15+
import 'package:zenit_ui/zenit_ui.dart';
1616

1717
void main() {
1818
runApp(const Terminal());
@@ -24,10 +24,13 @@ class Terminal extends StatelessWidget {
2424
@override
2525
Widget build(BuildContext context) {
2626
//setWindowTitle("Terminal");
27-
return FluentApp(
27+
return MaterialApp(
28+
debugShowCheckedModeBanner: false,
2829
title: 'Terminal',
2930
initialRoute: '/',
30-
theme: ThemeData(brightness: Brightness.dark),
31+
theme: ThemeEngine.zenitDefaultLightTheme,
32+
darkTheme: ThemeEngine.zenitDefaultDarkTheme,
33+
themeMode: ThemeMode.dark,
3134
routes: {
3235
"/": (context) => const TerminalFrame(),
3336
"/settings": (context) => const TerminalSettings(),

lib/views/terminal_frame.dart

Lines changed: 32 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import 'dart:io';
22

3-
import 'package:fluent_ui/fluent_ui.dart';
4-
import 'package:flutter/material.dart' as m;
53
import 'package:flutter_pty/flutter_pty.dart';
64
import 'package:terminal/constants/constants.dart';
7-
import 'package:terminal/views/terminal_settings.dart';
85
import 'package:xterm/frontend/terminal_view.dart';
96
import 'package:xterm/xterm.dart';
7+
import 'package:zenit_ui/zenit_ui.dart';
108

119
class TerminalFrame extends StatefulWidget {
1210
const TerminalFrame({Key? key}) : super(key: key);
@@ -36,83 +34,44 @@ String get shell {
3634
}
3735

3836
class _TerminalFrameState extends State<TerminalFrame> {
39-
int index = 0;
40-
List<Terminal> tabs = [Constants.terminal(_pty)];
41-
List<FocusNode> focusNodes = [FocusNode()];
42-
37+
final Map<FocusNode, Terminal> tabs = {
38+
FocusNode(): Constants.terminal(_pty),
39+
};
4340
@override
44-
void initState() {
45-
super.initState();
46-
47-
focusNodes[index].requestFocus();
41+
void didChangeDependencies() {
42+
super.didChangeDependencies();
43+
tabs.entries.first.key.requestFocus();
4844
}
4945

5046
@override
5147
Widget build(BuildContext context) {
52-
return m.Material(
48+
return Material(
5349
color: Colors.transparent,
54-
child: m.Theme(
55-
data: m.ThemeData(
56-
brightness: m.Brightness.dark,
57-
),
58-
child: TabView(
59-
wheelScroll: true,
60-
scrollController: ScrollPosController(),
61-
tabWidthBehavior: TabWidthBehavior.equal,
62-
showScrollButtons: true,
63-
shortcutsEnabled: true,
64-
currentIndex: index,
65-
footer: m.IconButton(
66-
onPressed: () {
67-
m.Navigator.of(context).push(
68-
m.MaterialPageRoute(
69-
builder: (context) => const TerminalSettings(),
70-
),
71-
);
72-
},
73-
icon: const m.Icon(m.Icons.settings_outlined),
74-
padding: EdgeInsets.zero,
75-
),
76-
onChanged: (newIndex) async {
77-
setState(() {
78-
index = newIndex;
79-
});
80-
await Future.delayed(const Duration(milliseconds: 300));
81-
focusNodes[newIndex].requestFocus();
82-
},
83-
onNewPressed: () async {
84-
setState(() {
85-
tabs.add(Constants.terminal(_pty));
86-
focusNodes.add(FocusNode());
87-
index = tabs.length - 1;
88-
});
89-
await Future.delayed(const Duration(milliseconds: 300));
90-
focusNodes[index].requestFocus();
91-
},
92-
tabs: List.generate(
93-
tabs.length,
94-
(mIndex) => Tab(
95-
text: Row(
96-
children: [
97-
Text("Terminal ${mIndex + 1}"),
98-
],
99-
),
100-
icon: const Icon(m.Icons.computer),
101-
onClosed: () {
102-
setState(() {
103-
tabs.removeAt(mIndex);
104-
index = tabs.length - 1;
105-
});
106-
},
107-
),
108-
),
109-
bodies: tabs
110-
.map((Terminal terminal) => TerminalView(
50+
child: TabView(
51+
pages: tabs
52+
.map((FocusNode focusNode, Terminal terminal) => MapEntry(
53+
focusNode,
54+
TabViewPage(
55+
title: "Terminal",
56+
view: TerminalView(
11157
terminal: terminal,
112-
focusNode: focusNodes[index],
113-
))
114-
.toList(),
115-
),
58+
focusNode: focusNode,
59+
),
60+
)))
61+
.values
62+
.toList(),
63+
onNewPage: () => setState(() {
64+
tabs.addEntries([MapEntry(FocusNode(), Constants.terminal(_pty))]);
65+
}),
66+
onPageClosed: (index) {
67+
tabs.removeWhere((key, value) =>
68+
tabs.entries.elementAt(index).key == key &&
69+
tabs.entries.elementAt(index).value == value);
70+
tabs.entries.elementAt(tabs.length - 1).key.requestFocus();
71+
},
72+
onPageChanged: (index) {
73+
tabs.entries.elementAt(index).key.requestFocus();
74+
},
11675
),
11776
);
11877
}

pubspec.lock

Lines changed: 126 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,14 @@ packages:
4949
name: convert
5050
url: "https://pub.dartlang.org"
5151
source: hosted
52-
version: "3.0.1"
52+
version: "3.0.2"
53+
crypto:
54+
dependency: transitive
55+
description:
56+
name: crypto
57+
url: "https://pub.dartlang.org"
58+
source: hosted
59+
version: "3.0.2"
5360
equatable:
5461
dependency: transitive
5562
description:
@@ -71,13 +78,13 @@ packages:
7178
url: "https://pub.dartlang.org"
7279
source: hosted
7380
version: "1.2.1"
74-
fluent_ui:
75-
dependency: "direct main"
81+
file:
82+
dependency: transitive
7683
description:
77-
name: fluent_ui
84+
name: file
7885
url: "https://pub.dartlang.org"
7986
source: hosted
80-
version: "3.12.0"
87+
version: "6.1.2"
8188
flutter:
8289
dependency: "direct main"
8390
description: flutter
@@ -90,30 +97,46 @@ packages:
9097
url: "https://pub.dartlang.org"
9198
source: hosted
9299
version: "2.0.1"
93-
flutter_localizations:
94-
dependency: transitive
95-
description: flutter
96-
source: sdk
97-
version: "0.0.0"
98100
flutter_pty:
99101
dependency: "direct main"
100102
description:
101103
name: flutter_pty
102104
url: "https://pub.dartlang.org"
103105
source: hosted
104-
version: "0.1.1"
106+
version: "0.2.0"
105107
flutter_test:
106108
dependency: "direct dev"
107109
description: flutter
108110
source: sdk
109111
version: "0.0.0"
110-
intl:
112+
gap:
113+
dependency: transitive
114+
description:
115+
name: gap
116+
url: "https://pub.dartlang.org"
117+
source: hosted
118+
version: "2.0.0"
119+
google_fonts:
120+
dependency: transitive
121+
description:
122+
name: google_fonts
123+
url: "https://pub.dartlang.org"
124+
source: hosted
125+
version: "2.3.3"
126+
http:
111127
dependency: transitive
112128
description:
113-
name: intl
129+
name: http
114130
url: "https://pub.dartlang.org"
115131
source: hosted
116-
version: "0.17.0"
132+
version: "0.13.4"
133+
http_parser:
134+
dependency: transitive
135+
description:
136+
name: http_parser
137+
url: "https://pub.dartlang.org"
138+
source: hosted
139+
version: "4.0.1"
117140
lints:
118141
dependency: transitive
119142
description:
@@ -149,34 +172,90 @@ packages:
149172
url: "https://pub.dartlang.org"
150173
source: hosted
151174
version: "1.8.1"
175+
path_provider:
176+
dependency: transitive
177+
description:
178+
name: path_provider
179+
url: "https://pub.dartlang.org"
180+
source: hosted
181+
version: "2.0.10"
182+
path_provider_android:
183+
dependency: transitive
184+
description:
185+
name: path_provider_android
186+
url: "https://pub.dartlang.org"
187+
source: hosted
188+
version: "2.0.14"
189+
path_provider_ios:
190+
dependency: transitive
191+
description:
192+
name: path_provider_ios
193+
url: "https://pub.dartlang.org"
194+
source: hosted
195+
version: "2.0.9"
196+
path_provider_linux:
197+
dependency: transitive
198+
description:
199+
name: path_provider_linux
200+
url: "https://pub.dartlang.org"
201+
source: hosted
202+
version: "2.1.7"
203+
path_provider_macos:
204+
dependency: transitive
205+
description:
206+
name: path_provider_macos
207+
url: "https://pub.dartlang.org"
208+
source: hosted
209+
version: "2.0.6"
210+
path_provider_platform_interface:
211+
dependency: transitive
212+
description:
213+
name: path_provider_platform_interface
214+
url: "https://pub.dartlang.org"
215+
source: hosted
216+
version: "2.0.4"
217+
path_provider_windows:
218+
dependency: transitive
219+
description:
220+
name: path_provider_windows
221+
url: "https://pub.dartlang.org"
222+
source: hosted
223+
version: "2.0.7"
224+
platform:
225+
dependency: transitive
226+
description:
227+
name: platform
228+
url: "https://pub.dartlang.org"
229+
source: hosted
230+
version: "3.1.0"
152231
platform_info:
153232
dependency: transitive
154233
description:
155234
name: platform_info
156235
url: "https://pub.dartlang.org"
157236
source: hosted
158-
version: "3.1.0"
159-
quiver:
237+
version: "3.2.0"
238+
plugin_platform_interface:
160239
dependency: transitive
161240
description:
162-
name: quiver
241+
name: plugin_platform_interface
163242
url: "https://pub.dartlang.org"
164243
source: hosted
165-
version: "3.1.0"
166-
recase:
244+
version: "2.1.2"
245+
process:
167246
dependency: transitive
168247
description:
169-
name: recase
248+
name: process
170249
url: "https://pub.dartlang.org"
171250
source: hosted
172-
version: "4.0.0"
173-
scroll_pos:
251+
version: "4.2.4"
252+
quiver:
174253
dependency: transitive
175254
description:
176-
name: scroll_pos
255+
name: quiver
177256
url: "https://pub.dartlang.org"
178257
source: hosted
179-
version: "0.3.0"
258+
version: "3.1.0"
180259
sky_engine:
181260
dependency: transitive
182261
description: flutter
@@ -238,6 +317,20 @@ packages:
238317
url: "https://pub.dartlang.org"
239318
source: hosted
240319
version: "2.1.2"
320+
win32:
321+
dependency: transitive
322+
description:
323+
name: win32
324+
url: "https://pub.dartlang.org"
325+
source: hosted
326+
version: "2.6.1"
327+
xdg_directories:
328+
dependency: transitive
329+
description:
330+
name: xdg_directories
331+
url: "https://pub.dartlang.org"
332+
source: hosted
333+
version: "0.2.0+1"
241334
xterm:
242335
dependency: "direct main"
243336
description:
@@ -247,6 +340,15 @@ packages:
247340
url: "https://github.com/TerminalStudio/xterm.dart.git"
248341
source: git
249342
version: "3.0.6-alpha"
343+
zenit_ui:
344+
dependency: "direct main"
345+
description:
346+
path: "."
347+
ref: HEAD
348+
resolved-ref: c3cd64944bb1b7b94ab7436f3da25ca56cfd7870
349+
url: "https://github.com/dahliaOS/zenit_ui.git"
350+
source: git
351+
version: "0.0.4"
250352
sdks:
251353
dart: ">=2.17.0 <3.0.0"
252354
flutter: ">=3.0.0"

pubspec.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ dependencies:
1414
git:
1515
url: https://github.com/TerminalStudio/xterm.dart.git
1616
ref: v3
17-
flutter_pty: ^0.1.1
17+
flutter_pty: ^0.2.0
1818
flutter_lints: ^2.0.1
19-
fluent_ui: 3.12.0
19+
zenit_ui:
20+
git: https://github.com/dahliaOS/zenit_ui.git
2021

2122
dev_dependencies:
2223
flutter_test:

0 commit comments

Comments
 (0)