mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-08-01 03:06:06 -04:00
example work
This commit is contained in:
parent
855a5a0756
commit
8c96373cfd
20 changed files with 713 additions and 30 deletions
80
veilid-flutter/example/lib/virtual_keyboard.dart
Normal file
80
veilid-flutter/example/lib/virtual_keyboard.dart
Normal file
|
@ -0,0 +1,80 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:xterm/xterm.dart';
|
||||
|
||||
class VirtualKeyboardView extends StatelessWidget {
|
||||
const VirtualKeyboardView(this.keyboard, {super.key});
|
||||
|
||||
final VirtualKeyboard keyboard;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedBuilder(
|
||||
animation: keyboard,
|
||||
builder: (context, child) => ToggleButtons(
|
||||
children: [Text('Ctrl'), Text('Alt'), Text('Shift')],
|
||||
isSelected: [keyboard.ctrl, keyboard.alt, keyboard.shift],
|
||||
onPressed: (index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
keyboard.ctrl = !keyboard.ctrl;
|
||||
break;
|
||||
case 1:
|
||||
keyboard.alt = !keyboard.alt;
|
||||
break;
|
||||
case 2:
|
||||
keyboard.shift = !keyboard.shift;
|
||||
break;
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class VirtualKeyboard extends TerminalInputHandler with ChangeNotifier {
|
||||
final TerminalInputHandler _inputHandler;
|
||||
|
||||
VirtualKeyboard(this._inputHandler);
|
||||
|
||||
bool _ctrl = false;
|
||||
|
||||
bool get ctrl => _ctrl;
|
||||
|
||||
set ctrl(bool value) {
|
||||
if (_ctrl != value) {
|
||||
_ctrl = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
bool _shift = false;
|
||||
|
||||
bool get shift => _shift;
|
||||
|
||||
set shift(bool value) {
|
||||
if (_shift != value) {
|
||||
_shift = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
bool _alt = false;
|
||||
|
||||
bool get alt => _alt;
|
||||
|
||||
set alt(bool value) {
|
||||
if (_alt != value) {
|
||||
_alt = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String? call(TerminalKeyboardEvent event) {
|
||||
return _inputHandler.call(event.copyWith(
|
||||
ctrl: event.ctrl || _ctrl,
|
||||
shift: event.shift || _shift,
|
||||
alt: event.alt || _alt,
|
||||
));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue