Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(orion_kb, settings): enhancement of OrionKB #22

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
9 changes: 9 additions & 0 deletions lib/settings/general_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ class GeneralCfgScreenState extends State<GeneralCfgScreen> {
.toString(),
scrollController:
_scrollController,
presetText: config
.getString('customUrl',
category:
'advanced'),
),
OrionKbExpander(
textFieldKey:
Expand Down Expand Up @@ -496,6 +500,11 @@ class GeneralCfgScreenState extends State<GeneralCfgScreen> {
.toString(),
scrollController:
_scrollController,
presetText:
config.getString(
'overrideRelease',
category:
'developer'),
),
OrionKbExpander(
textFieldKey:
Expand Down
12 changes: 11 additions & 1 deletion lib/settings/settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class SettingsScreenState extends State<SettingsScreen> {
GlobalKey<WifiScreenState>();
final ValueNotifier<bool> isConnected = ValueNotifier(false);
late Future<void> _wifiScreenFuture;
bool _isLinuxPlatform = false;

@override
void initState() {
Expand All @@ -70,8 +71,17 @@ class SettingsScreenState extends State<SettingsScreen> {
});
}

@override
void didChangeDependencies() {
super.didChangeDependencies();
_isLinuxPlatform = Theme.of(context).platform == TargetPlatform.linux;
if (_isLinuxPlatform) {
_checkInitialConnectionStatus();
}
}

Future<bool> _checkInitialConnectionStatus() async {
if (Theme.of(context).platform != TargetPlatform.linux) return false;
if (!_isLinuxPlatform) return false;
try {
// Get the default gateway IP address
final result = await Process.run('ip', ['route', 'show', 'default']);
Expand Down
55 changes: 38 additions & 17 deletions lib/util/orion_kb/orion_keyboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -296,15 +296,15 @@ class KeyboardButton extends StatelessWidget {
fit: BoxFit.scaleDown,
child: Text(
text,
style: const TextStyle(fontSize: 20),
style: const TextStyle(fontSize: 23),
),
);
}
return FittedBox(
fit: BoxFit.scaleDown,
child: Text(
isShiftEnabled ? text.toUpperCase() : text.toLowerCase(),
style: const TextStyle(fontSize: 20),
style: const TextStyle(fontSize: 23),
),
);
},
Expand Down Expand Up @@ -383,24 +383,45 @@ class KeyboardButton extends StatelessWidget {
}

// This method returns the background color for the keyboard button based on the text value.
// The brightness of the color is determined by a lookup table.
// The brightness of the color is determined by the theme mode.
Color? _getButtonBackgroundColor(BuildContext context) {
final isDarkMode = Theme.of(context).brightness == Brightness.dark;

const lightBrightness = {
'stdKey': 0.100,
'altKey': 0.200,
'highlight': 0.300,
};

const darkBrightness = {
'stdKey': 0.080,
'altKey': 0.050,
'highlight': 0.200,
};

final brightnessMap = isDarkMode ? darkBrightness : lightBrightness;

final lookupTable = {
// 3.0 is the brightness factor for the shift button
// 1.3 is the brightness factor for modifier keys
'⇧': isShiftEnabled.value ? 3.0 : 1.3,
'⇪': isCapsEnabled.value ? 3.0 : 1.3,
'⌫': 1.3,
'123': 1.3,
'abc': 1.3,
'return': 1.3,
'↵': 1.3,
'#+=': 1.3,
'123\u200B': 1.3,
'⇧': isShiftEnabled.value
? brightnessMap['highlight']
: brightnessMap['altKey'],
'⇪': isCapsEnabled.value
? brightnessMap['highlight']
: brightnessMap['altKey'],
'⌫': brightnessMap['altKey'],
'123': brightnessMap['altKey'],
'abc': brightnessMap['altKey'],
'return': brightnessMap['altKey'],
'↵': brightnessMap['altKey'],
'#+=': brightnessMap['altKey'],
'123\u200B': brightnessMap['altKey'],
};

// 1.8 is the brightness factor for all alphanumeric keys
final brightness = lookupTable[text] ?? 1.8;
return Theme.of(context).colorScheme.surface.withBrightness(brightness);
final brightness =
(lookupTable[text] ?? brightnessMap['stdKey']!).clamp(0.0, 1.0);
return Theme.of(context)
.colorScheme
.onPrimaryContainer
.withOpacity(brightness);
}
}
10 changes: 9 additions & 1 deletion lib/util/orion_kb/orion_keyboard_modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class OrionKbModal extends ModalRoute<String> {
bool get barrierDismissible => true;

@override
Color get barrierColor => Colors.black.withOpacity(0.2);
Color get barrierColor => Colors.black.withOpacity(0);

@override
String? get barrierLabel => null;
Expand All @@ -62,6 +62,14 @@ class OrionKbModal extends ModalRoute<String> {
topLeft: Radius.circular(radius),
topRight: Radius.circular(radius),
),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.35),
spreadRadius: 2,
blurRadius: 10,
offset: const Offset(0, 5),
),
],
),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 5.0),
Expand Down
11 changes: 5 additions & 6 deletions lib/util/orion_kb/orion_textfield.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,17 @@ class OrionTextFieldState extends State<OrionTextField>
return TextField(
controller: widget.controller,
readOnly: true,

decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: isKeyboardOpen
? Theme.of(context)
.colorScheme
.inversePrimary
.withBrightness(1.2)
? Theme.of(context).colorScheme.primaryContainer
: Theme.of(context).textTheme.bodyLarge!.color!,
),
),
labelText: widget.keyboardHint,
labelStyle:
const TextStyle(fontSize: 18), // Changed font size
),
// Hide the original text, We overlay our own with an animated line (cursor)
style: style.copyWith(
Expand Down Expand Up @@ -142,12 +140,13 @@ class OrionTextFieldState extends State<OrionTextField>
: Theme.of(context).textTheme.bodyLarge!.color!,
),
children: [
const WidgetSpan(child: SizedBox(width: 1)),
WidgetSpan(
child: Opacity(
opacity: _animController.value,
child: Container(
width: 1.5,
height: 20,
height: 22,
color: widget.isKeyboardOpen.value
? Theme.of(context)
.textTheme
Expand Down
5 changes: 5 additions & 0 deletions lib/util/orion_kb/orion_textfield_spawn.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class SpawnOrionTextField extends StatefulWidget {
final bool noShove;
final Function(String) onChanged;
final ScrollController? scrollController;
final String presetText;

const SpawnOrionTextField({
super.key,
Expand All @@ -37,6 +38,7 @@ class SpawnOrionTextField extends StatefulWidget {
this.noShove = false,
this.onChanged = _defaultOnChanged,
this.scrollController,
this.presetText = '',
});

// Do nothing
Expand All @@ -56,6 +58,9 @@ class SpawnOrionTextFieldState extends State<SpawnOrionTextField>
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
if (widget.presetText != '') {
_controller.text = '\u200B${widget.presetText}';
}
}

@override
Expand Down