Skip to content

Commit

Permalink
Switch to ZenitUI
Browse files Browse the repository at this point in the history
  • Loading branch information
larsb24 committed May 31, 2022
1 parent b5d3bfe commit a07fbc4
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 102 deletions.
9 changes: 6 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import 'package:fluent_ui/fluent_ui.dart';
import 'package:terminal/views/terminal_frame.dart';
import 'package:terminal/views/terminal_settings.dart';
import 'package:zenit_ui/zenit_ui.dart';

void main() {
runApp(const Terminal());
Expand All @@ -24,10 +24,13 @@ class Terminal extends StatelessWidget {
@override
Widget build(BuildContext context) {
//setWindowTitle("Terminal");
return FluentApp(
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Terminal',
initialRoute: '/',
theme: ThemeData(brightness: Brightness.dark),
theme: ThemeEngine.zenitDefaultLightTheme,
darkTheme: ThemeEngine.zenitDefaultDarkTheme,
themeMode: ThemeMode.dark,
routes: {
"/": (context) => const TerminalFrame(),
"/settings": (context) => const TerminalSettings(),
Expand Down
105 changes: 32 additions & 73 deletions lib/views/terminal_frame.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import 'dart:io';

import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/material.dart' as m;
import 'package:flutter_pty/flutter_pty.dart';
import 'package:terminal/constants/constants.dart';
import 'package:terminal/views/terminal_settings.dart';
import 'package:xterm/frontend/terminal_view.dart';
import 'package:xterm/xterm.dart';
import 'package:zenit_ui/zenit_ui.dart';

class TerminalFrame extends StatefulWidget {
const TerminalFrame({Key? key}) : super(key: key);
Expand Down Expand Up @@ -36,83 +34,44 @@ String get shell {
}

class _TerminalFrameState extends State<TerminalFrame> {
int index = 0;
List<Terminal> tabs = [Constants.terminal(_pty)];
List<FocusNode> focusNodes = [FocusNode()];

final Map<FocusNode, Terminal> tabs = {
FocusNode(): Constants.terminal(_pty),
};
@override
void initState() {
super.initState();

focusNodes[index].requestFocus();
void didChangeDependencies() {
super.didChangeDependencies();
tabs.entries.first.key.requestFocus();
}

@override
Widget build(BuildContext context) {
return m.Material(
return Material(
color: Colors.transparent,
child: m.Theme(
data: m.ThemeData(
brightness: m.Brightness.dark,
),
child: TabView(
wheelScroll: true,
scrollController: ScrollPosController(),
tabWidthBehavior: TabWidthBehavior.equal,
showScrollButtons: true,
shortcutsEnabled: true,
currentIndex: index,
footer: m.IconButton(
onPressed: () {
m.Navigator.of(context).push(
m.MaterialPageRoute(
builder: (context) => const TerminalSettings(),
),
);
},
icon: const m.Icon(m.Icons.settings_outlined),
padding: EdgeInsets.zero,
),
onChanged: (newIndex) async {
setState(() {
index = newIndex;
});
await Future.delayed(const Duration(milliseconds: 300));
focusNodes[newIndex].requestFocus();
},
onNewPressed: () async {
setState(() {
tabs.add(Constants.terminal(_pty));
focusNodes.add(FocusNode());
index = tabs.length - 1;
});
await Future.delayed(const Duration(milliseconds: 300));
focusNodes[index].requestFocus();
},
tabs: List.generate(
tabs.length,
(mIndex) => Tab(
text: Row(
children: [
Text("Terminal ${mIndex + 1}"),
],
),
icon: const Icon(m.Icons.computer),
onClosed: () {
setState(() {
tabs.removeAt(mIndex);
index = tabs.length - 1;
});
},
),
),
bodies: tabs
.map((Terminal terminal) => TerminalView(
child: TabView(
pages: tabs
.map((FocusNode focusNode, Terminal terminal) => MapEntry(
focusNode,
TabViewPage(
title: "Terminal",
view: TerminalView(
terminal: terminal,
focusNode: focusNodes[index],
))
.toList(),
),
focusNode: focusNode,
),
)))
.values
.toList(),
onNewPage: () => setState(() {
tabs.addEntries([MapEntry(FocusNode(), Constants.terminal(_pty))]);
}),
onPageClosed: (index) {
tabs.removeWhere((key, value) =>
tabs.entries.elementAt(index).key == key &&
tabs.entries.elementAt(index).value == value);
tabs.entries.elementAt(tabs.length - 1).key.requestFocus();
},
onPageChanged: (index) {
tabs.entries.elementAt(index).key.requestFocus();
},
),
);
}
Expand Down
148 changes: 124 additions & 24 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ packages:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
version: "3.0.2"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.2"
equatable:
dependency: transitive
description:
Expand All @@ -71,13 +78,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.1"
fluent_ui:
dependency: "direct main"
file:
dependency: transitive
description:
name: fluent_ui
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "3.12.0"
version: "6.1.2"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -90,30 +97,46 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
flutter_localizations:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
flutter_pty:
dependency: "direct main"
description:
name: flutter_pty
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1"
version: "0.2.0"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
intl:
gap:
dependency: transitive
description:
name: gap
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
google_fonts:
dependency: transitive
description:
name: google_fonts
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.3"
http:
dependency: transitive
description:
name: intl
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.17.0"
version: "0.13.4"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.1"
lints:
dependency: transitive
description:
Expand Down Expand Up @@ -149,34 +172,90 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
path_provider:
dependency: transitive
description:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.10"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.14"
path_provider_ios:
dependency: transitive
description:
name: path_provider_ios
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.9"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.7"
path_provider_macos:
dependency: transitive
description:
name: path_provider_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.6"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.7"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
platform_info:
dependency: transitive
description:
name: platform_info
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
quiver:
version: "3.2.0"
plugin_platform_interface:
dependency: transitive
description:
name: quiver
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
recase:
version: "2.1.2"
process:
dependency: transitive
description:
name: recase
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
scroll_pos:
version: "4.2.4"
quiver:
dependency: transitive
description:
name: scroll_pos
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0"
version: "3.1.0"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -238,6 +317,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.6.1"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0+1"
xterm:
dependency: "direct main"
description:
Expand All @@ -247,6 +340,13 @@ packages:
url: "https://github.com/TerminalStudio/xterm.dart.git"
source: git
version: "3.0.6-alpha"
zenit_ui:
dependency: "direct main"
description:
path: "../zenit_ui"
relative: true
source: path
version: "0.0.4"
sdks:
dart: ">=2.17.0 <3.0.0"
flutter: ">=3.0.0"
5 changes: 3 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ dependencies:
git:
url: https://github.com/TerminalStudio/xterm.dart.git
ref: v3
flutter_pty: ^0.1.1
flutter_pty: ^0.2.0
flutter_lints: ^2.0.1
fluent_ui: 3.12.0
zenit_ui:
path: ../zenit_ui

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit a07fbc4

Please sign in to comment.