-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
14 changed files
with
671 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:uni_control_hub/app/synergy/synergy_key_types.dart'; | ||
|
||
class ChooseHotkey extends StatefulWidget { | ||
const ChooseHotkey({super.key}); | ||
|
||
@override | ||
State<ChooseHotkey> createState() => _ChooseHotkeyState(); | ||
} | ||
|
||
class _ChooseHotkeyState extends State<ChooseHotkey> { | ||
String? selectedKey; | ||
String? selectedModifier; | ||
|
||
String? get result { | ||
if (selectedModifier != null && selectedKey == null) { | ||
return '$selectedModifier+__'; | ||
} else if (selectedKey != null && selectedModifier == null) { | ||
return selectedKey; | ||
} else if (selectedKey == null && selectedModifier == null) { | ||
return null; | ||
} else { | ||
return '$selectedModifier+$selectedKey'; | ||
} | ||
} | ||
|
||
void returnResult() { | ||
String? finalResult; | ||
// only use result if Key is not empty | ||
if (selectedKey != null) { | ||
finalResult = result; | ||
} | ||
Navigator.pop(context, finalResult); | ||
} | ||
|
||
FocusNode focusNode = FocusNode(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: const Text('Choose Hotkey'), | ||
leading: IconButton( | ||
onPressed: returnResult, | ||
icon: const Icon(Icons.arrow_back_ios), | ||
), | ||
), | ||
body: Column( | ||
children: [ | ||
const SizedBox(height: 10), | ||
Text('Result: ${result ?? '__'}'), | ||
const SizedBox(height: 10), | ||
const Row( | ||
mainAxisAlignment: MainAxisAlignment.spaceAround, | ||
children: [ | ||
Text('Modifier (Optional) '), | ||
Text('Key (Required)'), | ||
], | ||
), | ||
const Divider(), | ||
Expanded( | ||
child: Row( | ||
children: [ | ||
Expanded( | ||
child: ListView.builder( | ||
itemCount: synergyKeyModifierList.length, | ||
itemBuilder: (BuildContext context, int index) { | ||
String key = synergyKeyModifierList[index]; | ||
return Card( | ||
color: selectedModifier == key | ||
? Theme.of(context).colorScheme.primaryContainer | ||
: null, | ||
child: ListTile( | ||
title: Text(key), | ||
onTap: () { | ||
setState(() { | ||
if (key == selectedModifier) { | ||
selectedModifier = null; | ||
} else { | ||
selectedModifier = key; | ||
} | ||
}); | ||
}, | ||
), | ||
); | ||
}, | ||
), | ||
), | ||
const VerticalDivider(), | ||
Expanded( | ||
child: ListView.builder( | ||
itemCount: synergyKeyList.length, | ||
itemBuilder: (BuildContext context, int index) { | ||
String key = synergyKeyList[index]; | ||
return Card( | ||
color: selectedKey == key | ||
? Theme.of(context).colorScheme.primaryContainer | ||
: null, | ||
child: ListTile( | ||
title: Text(key), | ||
onTap: () { | ||
setState(() { | ||
if (key == selectedKey) { | ||
selectedKey = null; | ||
} else { | ||
selectedKey = key; | ||
} | ||
}); | ||
}, | ||
), | ||
); | ||
}, | ||
), | ||
), | ||
], | ||
), | ||
), | ||
Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: Row( | ||
children: [ | ||
Expanded( | ||
child: ElevatedButton( | ||
onPressed: () { | ||
setState(() { | ||
selectedKey = null; | ||
selectedModifier = null; | ||
}); | ||
returnResult(); | ||
}, | ||
child: const Text('Cancel'), | ||
), | ||
), | ||
const SizedBox(width: 10), | ||
Expanded( | ||
child: ElevatedButton( | ||
onPressed: returnResult, | ||
child: const Text('Set'), | ||
), | ||
), | ||
], | ||
), | ||
) | ||
], | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_settings_ui/flutter_settings_ui.dart'; | ||
import 'package:signals_flutter/signals_flutter.dart'; | ||
import 'package:uni_control_hub/app/data/dialog_handler.dart'; | ||
import 'package:uni_control_hub/app/data/info_data.dart'; | ||
import 'package:uni_control_hub/app/data/logger.dart'; | ||
import 'package:uni_control_hub/app/modules/setting/choose_hotkey.dart'; | ||
import 'package:uni_control_hub/app/services/synergy_service.dart'; | ||
|
||
class LockMouseTile extends StatelessWidget { | ||
const LockMouseTile({super.key}); | ||
|
||
void selectHotkey(BuildContext context, SynergyService synergyService) async { | ||
String? result = await Navigator.push( | ||
context, | ||
MaterialPageRoute( | ||
builder: (context) => const ChooseHotkey(), | ||
), | ||
); | ||
logInfo('Result $result'); | ||
synergyService.toggleKeyStroke.value = result; | ||
DialogHandler.showSuccess( | ||
"Changes will take effect after you restart the server", | ||
); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final synergyService = SynergyService.to; | ||
|
||
return Watch( | ||
(_) => SettingsTile( | ||
title: Row( | ||
children: [ | ||
const Text('Lock Mouse Hotkey'), | ||
const SizedBox(width: 10), | ||
InkWell( | ||
onTap: () { | ||
DialogHandler.showInfoDialog( | ||
context: context, | ||
title: 'Lock Mouse to Device', | ||
text: lockMouseTileInfo, | ||
); | ||
}, | ||
child: const Icon(Icons.info_outline, size: 19), | ||
) | ||
], | ||
), | ||
trailing: Text( | ||
synergyService.toggleKeyStroke.value ?? "Select Hotkey", | ||
), | ||
onPressed: (context) => selectHotkey(context, synergyService), | ||
leading: const Icon(Icons.ads_click), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.