NetDesk 1.5.0 — source release

This commit is contained in:
NetDesk committed 2026-10-18 02:02:46 +00:00
commit 40318aafdd
227 files changed
+80798

No files matched your search

+613
View File
@@ -0,0 +1,613 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'host_screen.dart';
import 'rust/api.dart' as nd;
import 'session_screen.dart';
import 'theme.dart';
/// Default NetDesk rendezvous / signaling endpoint (the Frankfurt VPS).
/// A LAN host is reachable by overriding this with `ws://<PC-IP>:8901/ws`
/// from the Advanced panel.
const String kDefaultServer = 'wss://netdesk.space/ws';
/// The landing / connect screen.
///
/// Mirrors the mental model of TeamViewer / RustDesk: the brand mark, a big
/// Partner ID field, a session password, and a primary Connect action. Connect
/// calls into the Rust core via flutter_rust_bridge ([nd.connect]) and hands
/// the returned session handle to the [SessionScreen].
class ConnectScreen extends StatefulWidget {
const ConnectScreen({super.key, this.initError});
/// Non-null when the native engine failed to load (shown as a banner).
final String? initError;
@override
State<ConnectScreen> createState() => _ConnectScreenState();
}
class _ConnectScreenState extends State<ConnectScreen> {
final TextEditingController _idController = TextEditingController();
final TextEditingController _passwordController = TextEditingController();
final TextEditingController _serverController =
TextEditingController(text: kDefaultServer);
bool _obscurePassword = true;
bool _showAdvanced = false;
bool _connecting = false;
@override
void dispose() {
_idController.dispose();
_passwordController.dispose();
_serverController.dispose();
super.dispose();
}
String get _digits => _idController.text.replaceAll(RegExp(r'\s'), '');
bool get _canConnect =>
!_connecting && _digits.length >= 6 && widget.initError == null;
Future<void> _connect() async {
if (!_canConnect) return;
FocusScope.of(context).unfocus();
final hostId = _digits;
final server = _serverController.text.trim().isEmpty
? kDefaultServer
: _serverController.text.trim();
setState(() => _connecting = true);
try {
final handle = await nd.connect(
wsUrl: server,
hostId: hostId,
password: _passwordController.text,
totp: '',
);
if (!mounted) return;
await Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) => SessionScreen(
partnerId: _idController.text.trim(),
handle: handle,
),
),
);
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
behavior: SnackBarBehavior.floating,
backgroundColor: NetDeskColors.surface,
content: Text('Could not start session: $e'),
),
);
}
} finally {
if (mounted) setState(() => _connecting = false);
}
}
/// The form half of the screen: error banner, connect card, device card and
/// the host-mode button. Shared by the narrow and the wide (two-pane) layouts.
List<Widget> _formChildren(BuildContext context) {
return [
if (widget.initError != null) ...[
_EngineErrorBanner(message: widget.initError!),
const SizedBox(height: NetDeskSpacing.md),
],
_ConnectCard(
idController: _idController,
passwordController: _passwordController,
serverController: _serverController,
obscurePassword: _obscurePassword,
canConnect: _canConnect,
connecting: _connecting,
showAdvanced: _showAdvanced,
onToggleObscure: () =>
setState(() => _obscurePassword = !_obscurePassword),
onToggleAdvanced: () => setState(() => _showAdvanced = !_showAdvanced),
onChanged: () => setState(() {}),
onConnect: _connect,
),
const SizedBox(height: NetDeskSpacing.md),
const _ThisDeviceCard(),
const SizedBox(height: NetDeskSpacing.md),
OutlinedButton.icon(
onPressed: () => Navigator.of(context).push(
MaterialPageRoute(builder: (_) => const HostScreen()),
),
icon: const Icon(Icons.phonelink_setup, size: 18),
label: const Text('Allow remote control of this device'),
style: OutlinedButton.styleFrom(
foregroundColor: NetDeskColors.textSecondary,
side: const BorderSide(color: NetDeskColors.border),
padding: const EdgeInsets.symmetric(vertical: 14),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(NetDeskRadius.md),
),
),
),
];
}
@override
Widget build(BuildContext context) {
// Responsive: the screen must FIT the window on phones, tablets (either
// orientation), split-screen and desktop/DeX windows.
// * wide windows -> brand beside the form (two panes, half the height)
// * short windows -> compact brand + tighter spacing
// * scrolling only remains as a last-resort safety for tiny windows.
return Scaffold(
body: SafeArea(
child: LayoutBuilder(
builder: (context, box) {
final wide = box.maxWidth >= 720;
final compact = box.maxHeight < 700;
if (wide) {
return Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
_Wordmark(),
SizedBox(height: NetDeskSpacing.lg),
_FooterNote(),
],
),
),
Expanded(
child: Center(
child: SingleChildScrollView(
padding: const EdgeInsets.all(NetDeskSpacing.lg),
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 440),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: _formChildren(context),
),
),
),
),
),
],
);
}
return Center(
child: SingleChildScrollView(
padding: EdgeInsets.all(
compact ? NetDeskSpacing.md : NetDeskSpacing.lg),
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 440),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_Wordmark(compact: compact),
SizedBox(
height: compact
? NetDeskSpacing.md
: NetDeskSpacing.xl),
..._formChildren(context),
SizedBox(
height: compact
? NetDeskSpacing.md
: NetDeskSpacing.lg),
const _FooterNote(),
],
),
),
),
);
},
),
),
);
}
}
/// Brand mark: the NetDesk logo, wordmark and the Akronlogic byline.
/// `compact` shrinks it so short windows (landscape phones, small desktop
/// windows) still fit the whole screen without scrolling.
class _Wordmark extends StatelessWidget {
const _Wordmark({this.compact = false});
final bool compact;
@override
Widget build(BuildContext context) {
final logo = compact ? 54.0 : 76.0;
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: logo,
height: logo,
padding: EdgeInsets.all(compact ? 7 : 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(NetDeskRadius.lg),
color: NetDeskColors.surface,
border: Border.all(color: NetDeskColors.border),
boxShadow: const [
BoxShadow(
color: NetDeskColors.accentGlow,
blurRadius: 36,
spreadRadius: 1,
),
],
),
child: Image.asset(
'assets/icon.png',
fit: BoxFit.contain,
filterQuality: FilterQuality.medium,
),
),
SizedBox(height: compact ? NetDeskSpacing.sm : NetDeskSpacing.md),
Text(
'NetDesk',
style: TextStyle(
fontSize: compact ? 28 : 40,
fontWeight: FontWeight.w800,
letterSpacing: -0.5,
color: NetDeskColors.textPrimary,
),
),
const SizedBox(height: 2),
Text(
'by Akronlogic',
style: TextStyle(
fontSize: compact ? 12 : 13,
fontWeight: FontWeight.w600,
letterSpacing: 2.4,
color: NetDeskColors.textSecondary.withValues(alpha: 0.9),
),
),
],
);
}
}
/// The main card: Partner ID + password + Connect (+ optional Advanced server).
class _ConnectCard extends StatelessWidget {
const _ConnectCard({
required this.idController,
required this.passwordController,
required this.serverController,
required this.obscurePassword,
required this.canConnect,
required this.connecting,
required this.showAdvanced,
required this.onToggleObscure,
required this.onToggleAdvanced,
required this.onChanged,
required this.onConnect,
});
final TextEditingController idController;
final TextEditingController passwordController;
final TextEditingController serverController;
final bool obscurePassword;
final bool canConnect;
final bool connecting;
final bool showAdvanced;
final VoidCallback onToggleObscure;
final VoidCallback onToggleAdvanced;
final VoidCallback onChanged;
final VoidCallback onConnect;
@override
Widget build(BuildContext context) {
return Card(
child: Padding(
padding: const EdgeInsets.all(NetDeskSpacing.lg),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const _FieldLabel('Partner ID'),
const SizedBox(height: NetDeskSpacing.xs),
TextField(
controller: idController,
onChanged: (_) => onChanged(),
enabled: !connecting,
keyboardType: TextInputType.number,
textInputAction: TextInputAction.next,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
_PartnerIdFormatter(),
],
style: const TextStyle(
fontSize: 22,
fontWeight: FontWeight.w700,
letterSpacing: 3,
color: NetDeskColors.textPrimary,
),
decoration: const InputDecoration(
hintText: '000 000 000',
prefixIcon:
Icon(Icons.badge_outlined, color: NetDeskColors.textMuted),
),
),
const SizedBox(height: NetDeskSpacing.md),
const _FieldLabel('Password'),
const SizedBox(height: NetDeskSpacing.xs),
TextField(
controller: passwordController,
onChanged: (_) => onChanged(),
enabled: !connecting,
obscureText: obscurePassword,
onSubmitted: (_) => canConnect ? onConnect() : null,
decoration: InputDecoration(
hintText: 'Session password',
prefixIcon: const Icon(Icons.lock_outline,
color: NetDeskColors.textMuted),
suffixIcon: IconButton(
tooltip: obscurePassword ? 'Show' : 'Hide',
onPressed: onToggleObscure,
icon: Icon(
obscurePassword
? Icons.visibility_outlined
: Icons.visibility_off_outlined,
),
),
),
),
AnimatedCrossFade(
duration: const Duration(milliseconds: 180),
crossFadeState: showAdvanced
? CrossFadeState.showSecond
: CrossFadeState.showFirst,
firstChild: const SizedBox(width: double.infinity),
secondChild: Padding(
padding: const EdgeInsets.only(top: NetDeskSpacing.md),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const _FieldLabel('Server'),
const SizedBox(height: NetDeskSpacing.xs),
TextField(
controller: serverController,
enabled: !connecting,
keyboardType: TextInputType.url,
autocorrect: false,
style: const TextStyle(
fontSize: 14,
color: NetDeskColors.textPrimary,
),
decoration: const InputDecoration(
hintText: 'wss://netdesk.space/ws',
prefixIcon: Icon(Icons.dns_outlined,
color: NetDeskColors.textMuted),
),
),
],
),
),
),
const SizedBox(height: NetDeskSpacing.lg),
FilledButton.icon(
onPressed: canConnect ? onConnect : null,
icon: connecting
? const SizedBox(
width: 18,
height: 18,
child: CircularProgressIndicator(
strokeWidth: 2.2,
color: Color(0xFF04210F),
),
)
: const Icon(Icons.bolt_rounded, size: 20),
label: Text(connecting ? 'Connecting…' : 'Connect'),
),
const SizedBox(height: NetDeskSpacing.xs),
Align(
alignment: Alignment.center,
child: TextButton.icon(
onPressed: onToggleAdvanced,
style: TextButton.styleFrom(
foregroundColor: NetDeskColors.textMuted,
textStyle: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
icon: Icon(
showAdvanced
? Icons.keyboard_arrow_up_rounded
: Icons.tune_rounded,
size: 16,
),
label: Text(showAdvanced ? 'Hide advanced' : 'Advanced'),
),
),
],
),
),
);
}
}
/// Small card standing in for *this* device's own shareable identity.
class _ThisDeviceCard extends StatelessWidget {
const _ThisDeviceCard();
@override
Widget build(BuildContext context) {
return Card(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: NetDeskSpacing.lg,
vertical: NetDeskSpacing.md,
),
child: Row(
children: [
Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: NetDeskColors.accentGlow,
borderRadius: BorderRadius.circular(NetDeskRadius.sm),
),
child: const Icon(Icons.smartphone_rounded,
color: NetDeskColors.accent, size: 20),
),
const SizedBox(width: NetDeskSpacing.md),
const Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'This device',
style: TextStyle(
fontSize: 12,
letterSpacing: 0.4,
color: NetDeskColors.textMuted,
),
),
SizedBox(height: 2),
Text(
'Incoming control — tap “Allow” below',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: NetDeskColors.textSecondary,
),
),
],
),
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
decoration: BoxDecoration(
color: NetDeskColors.surfaceAlt,
borderRadius: BorderRadius.circular(999),
border: Border.all(color: NetDeskColors.border),
),
child: const Text(
'BETA',
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.w700,
letterSpacing: 1,
color: NetDeskColors.textMuted,
),
),
),
],
),
),
);
}
}
class _EngineErrorBanner extends StatelessWidget {
const _EngineErrorBanner({required this.message});
final String message;
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(NetDeskSpacing.md),
decoration: BoxDecoration(
color: NetDeskColors.danger.withValues(alpha: 0.12),
borderRadius: BorderRadius.circular(NetDeskRadius.md),
border: Border.all(color: NetDeskColors.danger.withValues(alpha: 0.5)),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Icon(Icons.error_outline_rounded,
color: NetDeskColors.danger, size: 20),
const SizedBox(width: NetDeskSpacing.sm),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'Engine not loaded',
style: TextStyle(
fontWeight: FontWeight.w700,
color: NetDeskColors.textPrimary,
),
),
const SizedBox(height: 2),
Text(
message,
style: const TextStyle(
fontSize: 12,
color: NetDeskColors.textSecondary,
),
),
],
),
),
],
),
);
}
}
class _FieldLabel extends StatelessWidget {
const _FieldLabel(this.text);
final String text;
@override
Widget build(BuildContext context) {
return Text(
text.toUpperCase(),
style: const TextStyle(
fontSize: 11,
fontWeight: FontWeight.w700,
letterSpacing: 1.2,
color: NetDeskColors.textSecondary,
),
);
}
}
class _FooterNote extends StatelessWidget {
const _FooterNote();
@override
Widget build(BuildContext context) {
return const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.shield_outlined, size: 14, color: NetDeskColors.textMuted),
SizedBox(width: 6),
Text(
'End-to-end encrypted · v0.1.0',
style: TextStyle(fontSize: 12, color: NetDeskColors.textMuted),
),
],
);
}
}
/// Formats up to 12 digits as "123 456 789" while typing.
class _PartnerIdFormatter extends TextInputFormatter {
@override
TextEditingValue formatEditUpdate(
TextEditingValue oldValue,
TextEditingValue newValue,
) {
var digits = newValue.text.replaceAll(RegExp(r'\s'), '');
if (digits.length > 12) digits = digits.substring(0, 12);
final buffer = StringBuffer();
for (var i = 0; i < digits.length; i++) {
if (i != 0 && i % 3 == 0) buffer.write(' ');
buffer.write(digits[i]);
}
final formatted = buffer.toString();
return TextEditingValue(
text: formatted,
selection: TextSelection.collapsed(offset: formatted.length),
);
}
}
+539
View File
@@ -0,0 +1,539 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'rust/api.dart' as nd;
import 'theme.dart';
/// "Allow remote control" — the Android HOST role.
///
/// Turns this device into a NetDesk host (like RustDesk): once the user grants
/// screen capture and enables the accessibility service, a remote viewer can see
/// and control it. Talks to the native side over the `space.netdesk/host`
/// MethodChannel (see MainActivity.kt / HostService.kt).
///
/// Preview: screen capture + the controls are live; the remote-connection wiring
/// (register by Partner ID, send the encrypted H.264 to a viewer) lands next.
class HostScreen extends StatefulWidget {
const HostScreen({super.key});
@override
State<HostScreen> createState() => _HostScreenState();
}
class _HostScreenState extends State<HostScreen> with WidgetsBindingObserver {
static const _host = MethodChannel('space.netdesk/host');
static const _frameChannel = EventChannel('space.netdesk/frames');
static const _wsUrl = 'wss://netdesk.space/ws';
bool _running = false;
bool _accessibility = false;
bool _hideIcon = false;
bool _unattended = false;
int _frames = 0;
bool _busy = false;
// Rust host session.
BigInt? _handle;
String _id = '';
String _password = '';
bool _viewerConnected = false;
StreamSubscription<dynamic>? _frameSub;
StreamSubscription<nd.NdHostEvent>? _eventSub;
// Viewer-mouse -> touch gesture interpretation (coords are in capture space;
// MainActivity scales to the real display before injecting).
int _btns = 0;
double _downX = 0, _downY = 0, _lastX = 0, _lastY = 0;
int _downMs = 0;
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
_refresh();
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
_frameSub?.cancel();
_eventSub?.cancel();
super.dispose();
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.resumed) _refresh();
}
Future<T?> _call<T>(String method, [Map<String, dynamic>? args]) async {
try {
return await _host.invokeMethod<T>(method, args);
} catch (_) {
return null;
}
}
Future<void> _refresh() async {
final running = await _call<bool>('isHostRunning') ?? false;
final acc = await _call<bool>('hasAccessibility') ?? false;
final hide = await _call<bool>('isIconHidden') ?? false;
final un = await _call<bool>('isUnattended') ?? false;
final frames = await _call<int>('lastFrameCount') ?? 0;
if (mounted) {
setState(() {
_running = running;
_accessibility = acc;
_hideIcon = hide;
_unattended = un;
_frames = frames;
});
}
}
Future<void> _toggleHost() async {
setState(() => _busy = true);
if (_running) {
await _stopHostFull();
} else {
await _startHostFull();
}
if (mounted) setState(() => _busy = false);
}
/// Load the persisted host id + unattended password, generating them once.
Future<void> _loadCreds() async {
var id = await _call<String>('getHostId') ?? '';
var pw = await _call<String>('getHostPassword') ?? '';
if (id.isEmpty || pw.isEmpty) {
id = nd.hostGenId();
pw = nd.hostGenPassword();
await _call('setHostCreds', {'id': id, 'password': pw});
}
if (mounted) {
setState(() {
_id = id;
_password = pw;
});
}
}
Future<void> _startHostFull() async {
await _loadCreds();
// 1) screen-capture consent -> HostService starts encoding.
final ok = await _call<bool>('startHost') ?? false;
if (!ok) {
await _refresh();
return;
}
// 2) wait for the encoder to report a capture size.
int w = 0, h = 0;
for (var i = 0; i < 30; i++) {
await Future.delayed(const Duration(milliseconds: 200));
final s = await _call<Map<dynamic, dynamic>>('hostScreenSize');
if (s != null && (s['w'] as int? ?? 0) > 0) {
w = s['w'] as int;
h = s['h'] as int;
break;
}
}
if (w == 0) {
await _refresh();
return;
}
// 3) register the Rust host + wire frames out and input in.
final handle = await nd.hostStart(
wsUrl: _wsUrl,
hostId: _id,
name: 'Android',
password: _password,
width: w,
height: h,
);
_handle = handle;
_frameSub = _frameChannel.receiveBroadcastStream().listen(_onFrame);
_eventSub = nd.hostEvents(handle: handle).listen(_onHostEvent);
await _refresh();
}
Future<void> _stopHostFull() async {
await _frameSub?.cancel();
_frameSub = null;
await _eventSub?.cancel();
_eventSub = null;
final h = _handle;
_handle = null;
if (h != null) nd.hostStop(handle: h);
await _call('stopHost');
if (mounted) setState(() => _viewerConnected = false);
await Future.delayed(const Duration(milliseconds: 300));
await _refresh();
}
void _onFrame(dynamic payload) {
final h = _handle;
if (h == null || payload is! Uint8List || payload.isEmpty) return;
final keyframe = payload[0] == 1;
final data = Uint8List.sublistView(payload, 1);
nd.hostPushFrame(handle: h, data: data, keyframe: keyframe);
}
void _onHostEvent(nd.NdHostEvent ev) {
switch (ev) {
case nd.NdHostEvent_Mouse(:final x, :final y, :final buttons, :final wheel):
_onMouse(x, y, buttons, wheel);
case nd.NdHostEvent_Key(:final code, :final down):
_call('injectKey', {'code': code, 'down': down});
case nd.NdHostEvent_KeyframeRequested():
_call('requestKeyframe');
case nd.NdHostEvent_ViewerConnected():
if (mounted) setState(() => _viewerConnected = true);
case nd.NdHostEvent_ViewerLeft():
if (mounted) setState(() => _viewerConnected = false);
default:
break;
}
}
/// Translate the viewer's absolute pointer into Android gestures: a quick
/// press+release = tap, a moved drag = swipe, wheel = scroll.
void _onMouse(int x, int y, int buttons, double wheel) {
if (wheel != 0) {
final dy = (wheel.clamp(-3.0, 3.0) * 140).round();
_call('injectSwipe', {
'x1': x.toDouble(), 'y1': y.toDouble(),
'x2': x.toDouble(), 'y2': (y + dy).toDouble(), 'dur': 120,
});
return;
}
final leftNow = (buttons & 1) != 0;
final leftWas = (_btns & 1) != 0;
_btns = buttons;
if (leftNow && !leftWas) {
_downX = x.toDouble();
_downY = y.toDouble();
_lastX = _downX;
_lastY = _downY;
_downMs = DateTime.now().millisecondsSinceEpoch;
} else if (leftNow && leftWas) {
_lastX = x.toDouble();
_lastY = y.toDouble();
} else if (!leftNow && leftWas) {
_lastX = x.toDouble();
_lastY = y.toDouble();
final dist = (_lastX - _downX).abs() + (_lastY - _downY).abs();
if (dist < 12) {
_call('injectTap', {'x': _downX, 'y': _downY});
} else {
final dur = (DateTime.now().millisecondsSinceEpoch - _downMs)
.clamp(40, 800);
_call('injectSwipe', {
'x1': _downX, 'y1': _downY, 'x2': _lastX, 'y2': _lastY, 'dur': dur,
});
}
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: NetDeskColors.background,
appBar: AppBar(
backgroundColor: NetDeskColors.background,
elevation: 0,
title: const Text('Allow remote control'),
),
body: SafeArea(
child: RefreshIndicator(
color: NetDeskColors.accent,
onRefresh: _refresh,
child: ListView(
padding: const EdgeInsets.all(16),
children: [
_statusCard(),
if (_running && _id.isNotEmpty) ...[
const SizedBox(height: 14),
_credsCard(),
],
const SizedBox(height: 14),
_startStopButton(),
const SizedBox(height: 18),
_tile(
icon: Icons.touch_app_outlined,
title: 'Remote input (accessibility)',
subtitle: _accessibility
? 'Enabled — a viewer can tap and swipe this device.'
: 'Required so a viewer can tap and swipe. Tap to enable.',
trailing: _accessibility
? const Icon(Icons.check_circle, color: NetDeskColors.accent)
: const Icon(Icons.chevron_right,
color: NetDeskColors.textMuted),
onTap: _accessibility
? null
: () async {
await _call('openAccessibilitySettings');
},
),
_switchTile(
icon: Icons.schedule,
title: 'Unattended access',
subtitle: 'Start the host automatically after the device reboots.',
value: _unattended,
onChanged: (v) async {
await _call('setUnattended', {'on': v});
await _refresh();
},
),
_switchTile(
icon: Icons.visibility_off_outlined,
title: 'Hide app icon',
subtitle:
'Remove NetDesk from the app drawer (it keeps running). '
'Reopen it from your browser at netdesk.space.',
value: _hideIcon,
onChanged: (v) async {
await _call('setHideIcon', {'hide': v});
await _refresh();
},
),
const SizedBox(height: 16),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 4),
child: Text(
'Enter the ID and password above in any NetDesk viewer '
'(Windows, web or another phone) to see and control this '
'device. Keep the screen-capture notification on. '
'Developed by Akronlogic.',
style: TextStyle(
color: NetDeskColors.textMuted, fontSize: 12, height: 1.4),
),
),
],
),
),
),
);
}
Widget _statusCard() {
final on = _running;
return Container(
padding: const EdgeInsets.all(18),
decoration: BoxDecoration(
color: NetDeskColors.surface,
borderRadius: BorderRadius.circular(NetDeskRadius.lg),
border: Border.all(color: NetDeskColors.border),
),
child: Row(
children: [
Container(
width: 44,
height: 44,
decoration: BoxDecoration(
color: on ? NetDeskColors.accentGlow : NetDeskColors.surfaceAlt,
borderRadius: BorderRadius.circular(12),
),
child: Icon(
on ? Icons.cast_connected : Icons.cast,
color: on ? NetDeskColors.accent : NetDeskColors.textSecondary,
),
),
const SizedBox(width: 14),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
on ? 'Host is active' : 'Host is off',
style: const TextStyle(
color: NetDeskColors.textPrimary,
fontSize: 17,
fontWeight: FontWeight.w700,
),
),
const SizedBox(height: 2),
Text(
on
? 'Capturing the screen · $_frames frames encoded'
: 'This device cannot be controlled yet',
style: const TextStyle(
color: NetDeskColors.textSecondary, fontSize: 13),
),
],
),
),
],
),
);
}
Widget _credsCard() {
return Container(
padding: const EdgeInsets.all(18),
decoration: BoxDecoration(
color: NetDeskColors.surface,
borderRadius: BorderRadius.circular(NetDeskRadius.lg),
border: Border.all(
color: _viewerConnected ? NetDeskColors.accent : NetDeskColors.border,
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(
_viewerConnected ? Icons.lock_person : Icons.vpn_key_outlined,
size: 18,
color: _viewerConnected
? NetDeskColors.accent
: NetDeskColors.textSecondary,
),
const SizedBox(width: 8),
Text(
_viewerConnected ? 'A viewer is connected' : 'Ready for a viewer',
style: TextStyle(
color: _viewerConnected
? NetDeskColors.accent
: NetDeskColors.textSecondary,
fontSize: 13,
fontWeight: FontWeight.w600,
),
),
],
),
const SizedBox(height: 14),
_credRow('Your ID', _id),
const SizedBox(height: 10),
_credRow('Password', _password),
],
),
);
}
Widget _credRow(String label, String value) {
return Row(
children: [
SizedBox(
width: 86,
child: Text(label,
style: const TextStyle(
color: NetDeskColors.textMuted, fontSize: 13)),
),
Expanded(
child: SelectableText(
value,
style: const TextStyle(
color: NetDeskColors.textPrimary,
fontSize: 19,
fontWeight: FontWeight.w700,
letterSpacing: 1.5,
),
),
),
IconButton(
icon: const Icon(Icons.copy_rounded,
size: 18, color: NetDeskColors.textSecondary),
onPressed: () {
Clipboard.setData(ClipboardData(text: value));
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('$label copied'),
duration: const Duration(seconds: 1),
),
);
},
),
],
);
}
Widget _startStopButton() {
return SizedBox(
height: 52,
child: ElevatedButton(
onPressed: _busy ? null : _toggleHost,
style: ElevatedButton.styleFrom(
backgroundColor:
_running ? NetDeskColors.danger : NetDeskColors.accent,
foregroundColor: _running ? Colors.white : const Color(0xFF04210F),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(NetDeskRadius.md),
),
),
child: _busy
? const SizedBox(
width: 22,
height: 22,
child: CircularProgressIndicator(strokeWidth: 2.4),
)
: Text(
_running ? 'Stop hosting' : 'Start hosting this device',
style: const TextStyle(
fontSize: 16, fontWeight: FontWeight.w700),
),
),
);
}
Widget _tile({
required IconData icon,
required String title,
required String subtitle,
Widget? trailing,
VoidCallback? onTap,
}) {
return Container(
margin: const EdgeInsets.only(bottom: 10),
decoration: BoxDecoration(
color: NetDeskColors.surface,
borderRadius: BorderRadius.circular(NetDeskRadius.md),
border: Border.all(color: NetDeskColors.border),
),
child: ListTile(
onTap: onTap,
leading: Icon(icon, color: NetDeskColors.textSecondary),
title: Text(title,
style: const TextStyle(
color: NetDeskColors.textPrimary,
fontWeight: FontWeight.w600)),
subtitle: Text(subtitle,
style: const TextStyle(
color: NetDeskColors.textMuted, fontSize: 12.5)),
trailing: trailing,
),
);
}
Widget _switchTile({
required IconData icon,
required String title,
required String subtitle,
required bool value,
required ValueChanged<bool> onChanged,
}) {
return Container(
margin: const EdgeInsets.only(bottom: 10),
decoration: BoxDecoration(
color: NetDeskColors.surface,
borderRadius: BorderRadius.circular(NetDeskRadius.md),
border: Border.all(color: NetDeskColors.border),
),
child: SwitchListTile(
value: value,
onChanged: onChanged,
activeThumbColor: NetDeskColors.accent,
secondary: Icon(icon, color: NetDeskColors.textSecondary),
title: Text(title,
style: const TextStyle(
color: NetDeskColors.textPrimary,
fontWeight: FontWeight.w600)),
subtitle: Text(subtitle,
style: const TextStyle(
color: NetDeskColors.textMuted, fontSize: 12.5)),
),
);
}
}
+63
View File
@@ -0,0 +1,63 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'connect_screen.dart';
import 'rust/frb_generated.dart';
import 'theme.dart';
/// Entry point.
///
/// Before the first widget builds we initialise flutter_rust_bridge, which
/// loads the native `netdesk_frb` library (built from the Rust `netdesk-frb`
/// crate over `netdesk-core`). All session work — signaling, the transport,
/// input injection and the H.264 decode — runs behind that FFI layer; the Dart
/// side only paints frames and forwards input.
///
/// If the engine fails to load we still start the app, surfacing the error on
/// the connect screen instead of crashing to a black window.
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
// Behave like a true Android app: allow every orientation (tablets are used
// in landscape), and draw behind the system bars for an edge-to-edge look.
await SystemChrome.setPreferredOrientations(const [
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight,
]);
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
String? initError;
try {
await RustLib.init();
} catch (e) {
initError = '$e';
}
runApp(NetDeskApp(initError: initError));
}
/// Root application widget.
///
/// NetDesk is Akronlogic's premium cross-platform remote-desktop client. This
/// Flutter layer is the touch-native front-end; it binds to the Rust
/// `netdesk-core` crate via flutter_rust_bridge to drive the whole session.
class NetDeskApp extends StatelessWidget {
const NetDeskApp({super.key, this.initError});
/// Non-null when the native engine could not be loaded at startup.
final String? initError;
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'NetDesk',
debugShowCheckedModeBanner: false,
theme: NetDeskTheme.dark,
darkTheme: NetDeskTheme.dark,
themeMode: ThemeMode.dark,
home: ConnectScreen(initError: initError),
);
}
}
+258
View File
@@ -0,0 +1,258 @@
// This file is automatically generated, so please do not edit it.
// @generated by `flutter_rust_bridge`@ 2.13.0.
// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import
import 'frb_generated.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
import 'package:freezed_annotation/freezed_annotation.dart' hide protected;
part 'api.freezed.dart';
// These functions are ignored because they are not marked as `pub`: `cancels`, `host_cancels`, `host_frames`, `host_pending`, `map_host_event`, `pending`, `rgb_to_rgba`, `runtime`, `sessions`, `with_session`
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `clone`, `clone`, `clone`, `fmt`, `fmt`, `fmt`
/// Start a session against `ws_url` / `host_id` with `password` + `totp`, and
/// return its **handle**. The actual connect + handshake + H.264 decode run on
/// the background Tokio runtime; subscribe to the resulting [`NdEvent`]s with
/// [`session_events`] (passing this handle), and drive input / control with the
/// other functions here. A failed connect still returns a valid handle and
/// reports [`NdEvent::Ended`] / [`NdEvent::Denied`] on the stream.
Future<BigInt> connect(
{required String wsUrl,
required String hostId,
required String password,
required String totp}) =>
RustLib.instance.api.crateApiConnect(
wsUrl: wsUrl, hostId: hostId, password: password, totp: totp);
/// Subscribe to the [`NdEvent`] stream for a `handle` returned by [`connect`].
/// In Dart this is `Stream<NdEvent> sessionEvents({required BigInt handle})`.
/// Call it once per handle, right after `connect`.
Stream<NdEvent> sessionEvents({required BigInt handle}) =>
RustLib.instance.api.crateApiSessionEvents(handle: handle);
/// Send a pointer event (coordinates in the remote screen's pixel space).
/// `buttons` is the button bitmask, `wheel`/`hwheel` are scroll deltas.
void sendMouse(
{required BigInt handle,
required int x,
required int y,
required int buttons,
required double wheel,
required double hwheel}) =>
RustLib.instance.api.crateApiSendMouse(
handle: handle,
x: x,
y: y,
buttons: buttons,
wheel: wheel,
hwheel: hwheel);
/// Send a key event. `code` is a DOM-style key code (e.g. "KeyA", "Enter").
void sendKey(
{required BigInt handle, required String code, required bool down}) =>
RustLib.instance.api
.crateApiSendKey(handle: handle, code: code, down: down);
/// Reconfigure the host encoder: target `fps`, `bitrate` (kbps), resolution `scale`.
void setQuality(
{required BigInt handle,
required int fps,
required int bitrate,
required double scale}) =>
RustLib.instance.api.crateApiSetQuality(
handle: handle, fps: fps, bitrate: bitrate, scale: scale);
/// Switch the captured monitor to index `i` (as advertised by
/// [`session_monitors`]). Immediately asks the host for a fresh keyframe so the
/// new display paints without waiting for the next natural IDR — the messages
/// travel the same WebSocket in order, so the keyframe is of the *new* monitor.
void monitorSwitch({required BigInt handle, required int i}) =>
RustLib.instance.api.crateApiMonitorSwitch(handle: handle, i: i);
/// The real list of displays the host reported (its `info.monitors`). The UI
/// uses this to show exactly the monitors that exist — never a hardcoded count.
/// Returns empty until the session is accepted, or if the host sent none.
List<NdMonitor> sessionMonitors({required BigInt handle}) =>
RustLib.instance.api.crateApiSessionMonitors(handle: handle);
/// The monitor index the host is currently capturing (as reported at accept).
int sessionCurrentMonitor({required BigInt handle}) =>
RustLib.instance.api.crateApiSessionCurrentMonitor(handle: handle);
/// Send Ctrl+Alt+Del on the host.
void ctrlAltDel({required BigInt handle}) =>
RustLib.instance.api.crateApiCtrlAltDel(handle: handle);
/// Send a chat message to the host.
void sendChat({required BigInt handle, required String text}) =>
RustLib.instance.api.crateApiSendChat(handle: handle, text: text);
/// Push text to the remote clipboard (and announce our local clipboard).
void setClipboard({required BigInt handle, required String text}) =>
RustLib.instance.api.crateApiSetClipboard(handle: handle, text: text);
/// End the session: tell the host, then drop the handle. The event stream
/// receives a final [`NdEvent::Ended`] when the network task unwinds.
void disconnect({required BigInt handle}) =>
RustLib.instance.api.crateApiDisconnect(handle: handle);
/// A fresh 9-digit host id to persist on the device (shown to viewers).
String hostGenId() => RustLib.instance.api.crateApiHostGenId();
/// A fresh friendly unattended password (no look-alike chars).
String hostGenPassword() => RustLib.instance.api.crateApiHostGenPassword();
/// Start hosting: register `host_id` with the server and serve one viewer at a
/// time, authenticating against `password`. Returns a handle; drive input/
/// control via [`host_events`], feed video via [`host_push_frame`], stop with
/// [`host_stop`]. Credentials are derived fresh from `password` each run (the
/// challenge carries the salt, so the viewer only needs the password).
Future<BigInt> hostStart(
{required String wsUrl,
required String hostId,
required String name,
required String password,
required int width,
required int height}) =>
RustLib.instance.api.crateApiHostStart(
wsUrl: wsUrl,
hostId: hostId,
name: name,
password: password,
width: width,
height: height);
/// Subscribe to the [`NdHostEvent`] stream for a `handle` from [`host_start`].
Stream<NdHostEvent> hostEvents({required BigInt handle}) =>
RustLib.instance.api.crateApiHostEvents(handle: handle);
/// Feed one encoded H.264 access unit (Annex-B) from the platform encoder. Cheap
/// + non-blocking; dropped when no viewer is connected.
void hostPushFrame(
{required BigInt handle,
required List<int> data,
required bool keyframe}) =>
RustLib.instance.api
.crateApiHostPushFrame(handle: handle, data: data, keyframe: keyframe);
/// Stop hosting: end the reconnect loop and drop the handle.
void hostStop({required BigInt handle}) =>
RustLib.instance.api.crateApiHostStop(handle: handle);
@freezed
sealed class NdEvent with _$NdEvent {
const NdEvent._();
/// The WebSocket is dialing / the handshake is in flight.
const factory NdEvent.connecting() = NdEvent_Connecting;
/// Session accepted; the remote screen is about to stream.
const factory NdEvent.connected({
required int w,
required int h,
required bool e2E,
required String hostName,
}) = NdEvent_Connected;
/// A decoded, paint-ready frame: tightly-packed RGBA8 (`width*height*4`).
const factory NdEvent.frame({
required int width,
required int height,
required Uint8List rgba,
}) = NdEvent_Frame;
/// The session ended (socket closed, host ended it, connect failed, …).
const factory NdEvent.ended({
required String reason,
}) = NdEvent_Ended;
/// The host refused the session (bad password/TOTP, busy, blocked, …).
const factory NdEvent.denied({
required String reason,
}) = NdEvent_Denied;
/// A chat message from the host.
const factory NdEvent.chatMessage({
required String from,
required String text,
}) = NdEvent_ChatMessage;
/// Remote clipboard text pushed by the host (RustDesk-style sync).
const factory NdEvent.clipboard({
required String text,
}) = NdEvent_Clipboard;
}
@freezed
sealed class NdHostEvent with _$NdHostEvent {
const NdHostEvent._();
/// Registered with the server; the device is reachable at its host id.
const factory NdHostEvent.registered() = NdHostEvent_Registered;
/// A viewer authenticated; the session is live (inject input, feed frames).
const factory NdHostEvent.viewerConnected({
required bool e2E,
}) = NdHostEvent_ViewerConnected;
/// The viewer left; the host stays registered for the next one.
const factory NdHostEvent.viewerLeft() = NdHostEvent_ViewerLeft;
/// Pointer in the captured image's pixel space (buttons = bitmask).
const factory NdHostEvent.mouse({
required int x,
required int y,
required int buttons,
required double wheel,
}) = NdHostEvent_Mouse;
/// Key: DOM-style code + down/up.
const factory NdHostEvent.key({
required String code,
required bool down,
}) = NdHostEvent_Key;
/// The viewer asked for a fresh keyframe — request one from the encoder.
const factory NdHostEvent.keyframeRequested() = NdHostEvent_KeyframeRequested;
/// The viewer changed quality targets.
const factory NdHostEvent.quality({
required int fps,
required int bitrate,
required double scale,
}) = NdHostEvent_Quality;
/// The server link dropped; auto-reconnecting.
const factory NdHostEvent.reconnecting() = NdHostEvent_Reconnecting;
/// The host loop stopped for good (host_stop / fatal).
const factory NdHostEvent.ended({
required String reason,
}) = NdHostEvent_Ended;
}
/// A display the host advertised at accept time (index + pixel size).
class NdMonitor {
final int i;
final int w;
final int h;
const NdMonitor({
required this.i,
required this.w,
required this.h,
});
@override
int get hashCode => i.hashCode ^ w.hashCode ^ h.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is NdMonitor &&
runtimeType == other.runtimeType &&
i == other.i &&
w == other.w &&
h == other.h;
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+196
View File
@@ -0,0 +1,196 @@
// This file is automatically generated, so please do not edit it.
// @generated by `flutter_rust_bridge`@ 2.13.0.
// ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field
import 'api.dart';
import 'dart:async';
import 'dart:convert';
import 'dart:ffi' as ffi;
import 'frb_generated.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated_io.dart';
abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
RustLibApiImplPlatform({
required super.handler,
required super.wire,
required super.generalizedFrbRustBinding,
required super.portManager,
});
@protected
AnyhowException dco_decode_AnyhowException(dynamic raw);
@protected
RustStreamSink<NdEvent> dco_decode_StreamSink_nd_event_Sse(dynamic raw);
@protected
RustStreamSink<NdHostEvent> dco_decode_StreamSink_nd_host_event_Sse(
dynamic raw);
@protected
String dco_decode_String(dynamic raw);
@protected
bool dco_decode_bool(dynamic raw);
@protected
double dco_decode_f_32(dynamic raw);
@protected
int dco_decode_i_32(dynamic raw);
@protected
List<NdMonitor> dco_decode_list_nd_monitor(dynamic raw);
@protected
List<int> dco_decode_list_prim_u_8_loose(dynamic raw);
@protected
Uint8List dco_decode_list_prim_u_8_strict(dynamic raw);
@protected
NdEvent dco_decode_nd_event(dynamic raw);
@protected
NdHostEvent dco_decode_nd_host_event(dynamic raw);
@protected
NdMonitor dco_decode_nd_monitor(dynamic raw);
@protected
int dco_decode_u_32(dynamic raw);
@protected
BigInt dco_decode_u_64(dynamic raw);
@protected
int dco_decode_u_8(dynamic raw);
@protected
void dco_decode_unit(dynamic raw);
@protected
AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer);
@protected
RustStreamSink<NdEvent> sse_decode_StreamSink_nd_event_Sse(
SseDeserializer deserializer);
@protected
RustStreamSink<NdHostEvent> sse_decode_StreamSink_nd_host_event_Sse(
SseDeserializer deserializer);
@protected
String sse_decode_String(SseDeserializer deserializer);
@protected
bool sse_decode_bool(SseDeserializer deserializer);
@protected
double sse_decode_f_32(SseDeserializer deserializer);
@protected
int sse_decode_i_32(SseDeserializer deserializer);
@protected
List<NdMonitor> sse_decode_list_nd_monitor(SseDeserializer deserializer);
@protected
List<int> sse_decode_list_prim_u_8_loose(SseDeserializer deserializer);
@protected
Uint8List sse_decode_list_prim_u_8_strict(SseDeserializer deserializer);
@protected
NdEvent sse_decode_nd_event(SseDeserializer deserializer);
@protected
NdHostEvent sse_decode_nd_host_event(SseDeserializer deserializer);
@protected
NdMonitor sse_decode_nd_monitor(SseDeserializer deserializer);
@protected
int sse_decode_u_32(SseDeserializer deserializer);
@protected
BigInt sse_decode_u_64(SseDeserializer deserializer);
@protected
int sse_decode_u_8(SseDeserializer deserializer);
@protected
void sse_decode_unit(SseDeserializer deserializer);
@protected
void sse_encode_AnyhowException(
AnyhowException self, SseSerializer serializer);
@protected
void sse_encode_StreamSink_nd_event_Sse(
RustStreamSink<NdEvent> self, SseSerializer serializer);
@protected
void sse_encode_StreamSink_nd_host_event_Sse(
RustStreamSink<NdHostEvent> self, SseSerializer serializer);
@protected
void sse_encode_String(String self, SseSerializer serializer);
@protected
void sse_encode_bool(bool self, SseSerializer serializer);
@protected
void sse_encode_f_32(double self, SseSerializer serializer);
@protected
void sse_encode_i_32(int self, SseSerializer serializer);
@protected
void sse_encode_list_nd_monitor(
List<NdMonitor> self, SseSerializer serializer);
@protected
void sse_encode_list_prim_u_8_loose(List<int> self, SseSerializer serializer);
@protected
void sse_encode_list_prim_u_8_strict(
Uint8List self, SseSerializer serializer);
@protected
void sse_encode_nd_event(NdEvent self, SseSerializer serializer);
@protected
void sse_encode_nd_host_event(NdHostEvent self, SseSerializer serializer);
@protected
void sse_encode_nd_monitor(NdMonitor self, SseSerializer serializer);
@protected
void sse_encode_u_32(int self, SseSerializer serializer);
@protected
void sse_encode_u_64(BigInt self, SseSerializer serializer);
@protected
void sse_encode_u_8(int self, SseSerializer serializer);
@protected
void sse_encode_unit(void self, SseSerializer serializer);
}
// Section: wire_class
class RustLibWire implements BaseWire {
factory RustLibWire.fromExternalLibrary(ExternalLibrary lib) =>
RustLibWire(lib.ffiDynamicLibrary);
/// Holds the symbol lookup function.
final ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
_lookup;
/// The symbols are looked up in [dynamicLibrary].
RustLibWire(ffi.DynamicLibrary dynamicLibrary)
: _lookup = dynamicLibrary.lookup;
}
+196
View File
@@ -0,0 +1,196 @@
// This file is automatically generated, so please do not edit it.
// @generated by `flutter_rust_bridge`@ 2.13.0.
// ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field
// Static analysis wrongly picks the IO variant, thus ignore this
// ignore_for_file: argument_type_not_assignable
import 'api.dart';
import 'dart:async';
import 'dart:convert';
import 'frb_generated.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated_web.dart';
abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
RustLibApiImplPlatform({
required super.handler,
required super.wire,
required super.generalizedFrbRustBinding,
required super.portManager,
});
@protected
AnyhowException dco_decode_AnyhowException(dynamic raw);
@protected
RustStreamSink<NdEvent> dco_decode_StreamSink_nd_event_Sse(dynamic raw);
@protected
RustStreamSink<NdHostEvent> dco_decode_StreamSink_nd_host_event_Sse(
dynamic raw);
@protected
String dco_decode_String(dynamic raw);
@protected
bool dco_decode_bool(dynamic raw);
@protected
double dco_decode_f_32(dynamic raw);
@protected
int dco_decode_i_32(dynamic raw);
@protected
List<NdMonitor> dco_decode_list_nd_monitor(dynamic raw);
@protected
List<int> dco_decode_list_prim_u_8_loose(dynamic raw);
@protected
Uint8List dco_decode_list_prim_u_8_strict(dynamic raw);
@protected
NdEvent dco_decode_nd_event(dynamic raw);
@protected
NdHostEvent dco_decode_nd_host_event(dynamic raw);
@protected
NdMonitor dco_decode_nd_monitor(dynamic raw);
@protected
int dco_decode_u_32(dynamic raw);
@protected
BigInt dco_decode_u_64(dynamic raw);
@protected
int dco_decode_u_8(dynamic raw);
@protected
void dco_decode_unit(dynamic raw);
@protected
AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer);
@protected
RustStreamSink<NdEvent> sse_decode_StreamSink_nd_event_Sse(
SseDeserializer deserializer);
@protected
RustStreamSink<NdHostEvent> sse_decode_StreamSink_nd_host_event_Sse(
SseDeserializer deserializer);
@protected
String sse_decode_String(SseDeserializer deserializer);
@protected
bool sse_decode_bool(SseDeserializer deserializer);
@protected
double sse_decode_f_32(SseDeserializer deserializer);
@protected
int sse_decode_i_32(SseDeserializer deserializer);
@protected
List<NdMonitor> sse_decode_list_nd_monitor(SseDeserializer deserializer);
@protected
List<int> sse_decode_list_prim_u_8_loose(SseDeserializer deserializer);
@protected
Uint8List sse_decode_list_prim_u_8_strict(SseDeserializer deserializer);
@protected
NdEvent sse_decode_nd_event(SseDeserializer deserializer);
@protected
NdHostEvent sse_decode_nd_host_event(SseDeserializer deserializer);
@protected
NdMonitor sse_decode_nd_monitor(SseDeserializer deserializer);
@protected
int sse_decode_u_32(SseDeserializer deserializer);
@protected
BigInt sse_decode_u_64(SseDeserializer deserializer);
@protected
int sse_decode_u_8(SseDeserializer deserializer);
@protected
void sse_decode_unit(SseDeserializer deserializer);
@protected
void sse_encode_AnyhowException(
AnyhowException self, SseSerializer serializer);
@protected
void sse_encode_StreamSink_nd_event_Sse(
RustStreamSink<NdEvent> self, SseSerializer serializer);
@protected
void sse_encode_StreamSink_nd_host_event_Sse(
RustStreamSink<NdHostEvent> self, SseSerializer serializer);
@protected
void sse_encode_String(String self, SseSerializer serializer);
@protected
void sse_encode_bool(bool self, SseSerializer serializer);
@protected
void sse_encode_f_32(double self, SseSerializer serializer);
@protected
void sse_encode_i_32(int self, SseSerializer serializer);
@protected
void sse_encode_list_nd_monitor(
List<NdMonitor> self, SseSerializer serializer);
@protected
void sse_encode_list_prim_u_8_loose(List<int> self, SseSerializer serializer);
@protected
void sse_encode_list_prim_u_8_strict(
Uint8List self, SseSerializer serializer);
@protected
void sse_encode_nd_event(NdEvent self, SseSerializer serializer);
@protected
void sse_encode_nd_host_event(NdHostEvent self, SseSerializer serializer);
@protected
void sse_encode_nd_monitor(NdMonitor self, SseSerializer serializer);
@protected
void sse_encode_u_32(int self, SseSerializer serializer);
@protected
void sse_encode_u_64(BigInt self, SseSerializer serializer);
@protected
void sse_encode_u_8(int self, SseSerializer serializer);
@protected
void sse_encode_unit(void self, SseSerializer serializer);
}
// Section: wire_class
class RustLibWire implements BaseWire {
RustLibWire.fromExternalLibrary(ExternalLibrary lib);
}
@JS('wasm_bindgen')
external RustLibWasmModule get wasmModule;
@JS()
@anonymous
extension type RustLibWasmModule._(JSObject _) implements JSObject {}
File diff suppressed because it is too large. Load diff
+196
View File
@@ -0,0 +1,196 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
/// NetDesk design tokens + [ThemeData].
///
/// A single, dark, premium theme in the spirit of TeamViewer / RustDesk —
/// deep near-black surfaces, a confident green accent, generous spacing and
/// softly rounded cards. All colors live here as tokens so the rest of the
/// app never hardcodes a hex value.
class NetDeskColors {
NetDeskColors._();
/// App background — deep, near-black with a cool blue cast.
static const Color background = Color(0xFF0B0F15);
/// Raised surface (cards, panels) — one step lighter than the background.
static const Color surface = Color(0xFF121821);
/// A second elevation used for inputs / inset wells.
static const Color surfaceAlt = Color(0xFF0E141C);
/// Hairline borders and dividers.
static const Color border = Color(0xFF1E2733);
/// Primary brand accent — a vivid, trustworthy green.
static const Color accent = Color(0xFF22C55E);
/// Darker accent for pressed / gradient ends.
static const Color accentDeep = Color(0xFF16A34A);
/// Soft accent glow used sparingly behind the wordmark.
static const Color accentGlow = Color(0x3322C55E);
/// High-emphasis text.
static const Color textPrimary = Color(0xFFF2F5F9);
/// Medium-emphasis text (subtitles, labels).
static const Color textSecondary = Color(0xFF9AA7B8);
/// Low-emphasis text (hints, captions).
static const Color textMuted = Color(0xFF5E6B7D);
/// Destructive / disconnect actions.
static const Color danger = Color(0xFFEF4444);
}
class NetDeskRadius {
NetDeskRadius._();
static const double sm = 8;
static const double md = 12;
static const double lg = 16;
static const double xl = 22;
}
class NetDeskSpacing {
NetDeskSpacing._();
static const double xs = 6;
static const double sm = 10;
static const double md = 16;
static const double lg = 24;
static const double xl = 36;
}
class NetDeskTheme {
NetDeskTheme._();
static ThemeData get dark {
const scheme = ColorScheme.dark(
primary: NetDeskColors.accent,
onPrimary: Color(0xFF04210F),
secondary: NetDeskColors.accentDeep,
onSecondary: Color(0xFF04210F),
surface: NetDeskColors.surface,
onSurface: NetDeskColors.textPrimary,
error: NetDeskColors.danger,
onError: Colors.white,
outline: NetDeskColors.border,
);
final base = ThemeData.dark(useMaterial3: true);
return base.copyWith(
colorScheme: scheme,
scaffoldBackgroundColor: NetDeskColors.background,
canvasColor: NetDeskColors.background,
dividerColor: NetDeskColors.border,
splashFactory: InkSparkle.splashFactory,
textTheme: base.textTheme
.apply(
bodyColor: NetDeskColors.textPrimary,
displayColor: NetDeskColors.textPrimary,
fontFamily: 'Roboto',
)
.copyWith(
bodyMedium: const TextStyle(
color: NetDeskColors.textSecondary,
height: 1.4,
),
labelLarge: const TextStyle(
fontWeight: FontWeight.w600,
letterSpacing: 0.3,
),
),
appBarTheme: const AppBarTheme(
backgroundColor: NetDeskColors.surfaceAlt,
foregroundColor: NetDeskColors.textPrimary,
elevation: 0,
centerTitle: false,
titleTextStyle: TextStyle(
color: NetDeskColors.textPrimary,
fontSize: 16,
fontWeight: FontWeight.w600,
letterSpacing: 0.2,
),
systemOverlayStyle: SystemUiOverlayStyle.light,
),
cardTheme: CardThemeData(
color: NetDeskColors.surface,
elevation: 0,
margin: EdgeInsets.zero,
shape: RoundedRectangleBorder(
side: const BorderSide(color: NetDeskColors.border),
borderRadius: BorderRadius.circular(NetDeskRadius.xl),
),
),
inputDecorationTheme: InputDecorationTheme(
filled: true,
fillColor: NetDeskColors.surfaceAlt,
hintStyle: const TextStyle(color: NetDeskColors.textMuted),
labelStyle: const TextStyle(color: NetDeskColors.textSecondary),
contentPadding: const EdgeInsets.symmetric(
horizontal: NetDeskSpacing.md,
vertical: 18,
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(NetDeskRadius.md),
borderSide: const BorderSide(color: NetDeskColors.border),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(NetDeskRadius.md),
borderSide: const BorderSide(color: NetDeskColors.accent, width: 1.6),
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(NetDeskRadius.md),
borderSide: const BorderSide(color: NetDeskColors.danger),
),
),
filledButtonTheme: FilledButtonThemeData(
style: FilledButton.styleFrom(
backgroundColor: NetDeskColors.accent,
foregroundColor: const Color(0xFF04210F),
disabledBackgroundColor: NetDeskColors.border,
disabledForegroundColor: NetDeskColors.textMuted,
minimumSize: const Size.fromHeight(54),
textStyle: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.w700,
letterSpacing: 0.3,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(NetDeskRadius.md),
),
),
),
iconButtonTheme: IconButtonThemeData(
style: IconButton.styleFrom(
foregroundColor: NetDeskColors.textSecondary,
hoverColor: NetDeskColors.surface,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(NetDeskRadius.sm),
),
),
),
tooltipTheme: const TooltipThemeData(
decoration: BoxDecoration(
color: Color(0xFF1B2430),
borderRadius: BorderRadius.all(Radius.circular(NetDeskRadius.sm)),
),
textStyle: TextStyle(color: NetDeskColors.textPrimary, fontSize: 12),
),
dividerTheme: const DividerThemeData(
color: NetDeskColors.border,
thickness: 1,
space: 1,
),
);
}
}