Skip to content

Commit

Permalink
Merge pull request #867 from cypherstack/ui-fixes
Browse files Browse the repository at this point in the history
UI fixes
  • Loading branch information
julian-CStack committed May 14, 2024
2 parents 33c78a4 + 129c46f commit 7b95efa
Show file tree
Hide file tree
Showing 14 changed files with 819 additions and 556 deletions.
451 changes: 227 additions & 224 deletions lib/models/isar/stack_theme.dart

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -276,21 +276,21 @@ class _RestoreFrostMsWalletViewState
Constants.size.circularBorderRadius,
),
child: TextField(
key: const Key("frMyNameTextFieldKey"),
controller: keysFieldController,
key: const Key("frConfigTextFieldKey"),
controller: configFieldController,
onChanged: (_) {
setState(() {
_keysEmpty = keysFieldController.text.isEmpty;
_configEmpty = configFieldController.text.isEmpty;
});
},
focusNode: keysFocusNode,
focusNode: configFocusNode,
readOnly: false,
autocorrect: false,
enableSuggestions: false,
style: STextStyles.field(context),
decoration: standardInputDecoration(
"Keys",
keysFocusNode,
"Enter config",
configFocusNode,
context,
).copyWith(
contentPadding: const EdgeInsets.only(
Expand All @@ -300,50 +300,83 @@ class _RestoreFrostMsWalletViewState
right: 5,
),
suffixIcon: Padding(
padding: _keysEmpty
padding: _configEmpty
? const EdgeInsets.only(right: 8)
: const EdgeInsets.only(right: 0),
child: UnconstrainedBox(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
!_keysEmpty
!_configEmpty
? TextFieldIconButton(
semanticsLabel:
"Clear Button. Clears The Keys Field.",
key: const Key("frMyNameClearButtonKey"),
"Clear Button. Clears The Config Field.",
key: const Key("frConfigClearButtonKey"),
onTap: () {
keysFieldController.text = "";
configFieldController.text = "";

setState(() {
_keysEmpty = true;
_configEmpty = true;
});
},
child: const XIcon(),
)
: TextFieldIconButton(
semanticsLabel:
"Paste Button. Pastes From Clipboard To Keys Field.",
key: const Key("frKeysPasteButtonKey"),
"Paste Button. Pastes From Clipboard To Config Field Input.",
key: const Key("frConfigPasteButtonKey"),
onTap: () async {
final ClipboardData? data =
await Clipboard.getData(
Clipboard.kTextPlain);
Clipboard.kTextPlain,
);
if (data?.text != null &&
data!.text!.isNotEmpty) {
keysFieldController.text =
configFieldController.text =
data.text!.trim();
}

setState(() {
_keysEmpty =
keysFieldController.text.isEmpty;
_configEmpty =
configFieldController.text.isEmpty;
});
},
child: _keysEmpty
child: _configEmpty
? const ClipboardIcon()
: const XIcon(),
),
if (_configEmpty)
TextFieldIconButton(
semanticsLabel:
"Scan QR Button. Opens Camera For Scanning QR Code.",
key: const Key("frConfigScanQrButtonKey"),
onTap: () async {
try {
if (FocusScope.of(context).hasFocus) {
FocusScope.of(context).unfocus();
await Future<void>.delayed(
const Duration(milliseconds: 75),
);
}

final qrResult = await BarcodeScanner.scan();

configFieldController.text =
qrResult.rawContent;

setState(() {
_configEmpty =
configFieldController.text.isEmpty;
});
} on PlatformException catch (e, s) {
Logging.instance.log(
"Failed to get camera permissions while trying to scan qr code: $e\n$s",
level: LogLevel.Warning,
);
}
},
child: const QrCodeIcon(),
),
],
),
),
Expand All @@ -359,21 +392,21 @@ class _RestoreFrostMsWalletViewState
Constants.size.circularBorderRadius,
),
child: TextField(
key: const Key("frConfigTextFieldKey"),
controller: configFieldController,
key: const Key("frMyNameTextFieldKey"),
controller: keysFieldController,
onChanged: (_) {
setState(() {
_configEmpty = configFieldController.text.isEmpty;
_keysEmpty = keysFieldController.text.isEmpty;
});
},
focusNode: configFocusNode,
focusNode: keysFocusNode,
readOnly: false,
autocorrect: false,
enableSuggestions: false,
style: STextStyles.field(context),
decoration: standardInputDecoration(
"Enter config",
configFocusNode,
"Keys",
keysFocusNode,
context,
).copyWith(
contentPadding: const EdgeInsets.only(
Expand All @@ -383,81 +416,51 @@ class _RestoreFrostMsWalletViewState
right: 5,
),
suffixIcon: Padding(
padding: _configEmpty
padding: _keysEmpty
? const EdgeInsets.only(right: 8)
: const EdgeInsets.only(right: 0),
child: UnconstrainedBox(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
!_configEmpty
!_keysEmpty
? TextFieldIconButton(
semanticsLabel:
"Clear Button. Clears The Config Field.",
key: const Key("frConfigClearButtonKey"),
"Clear Button. Clears The Keys Field.",
key: const Key("frMyNameClearButtonKey"),
onTap: () {
configFieldController.text = "";
keysFieldController.text = "";

setState(() {
_configEmpty = true;
_keysEmpty = true;
});
},
child: const XIcon(),
)
: TextFieldIconButton(
semanticsLabel:
"Paste Button. Pastes From Clipboard To Config Field Input.",
key: const Key("frConfigPasteButtonKey"),
"Paste Button. Pastes From Clipboard To Keys Field.",
key: const Key("frKeysPasteButtonKey"),
onTap: () async {
final ClipboardData? data =
await Clipboard.getData(
Clipboard.kTextPlain);
Clipboard.kTextPlain,
);
if (data?.text != null &&
data!.text!.isNotEmpty) {
configFieldController.text =
keysFieldController.text =
data.text!.trim();
}

setState(() {
_configEmpty =
configFieldController.text.isEmpty;
_keysEmpty =
keysFieldController.text.isEmpty;
});
},
child: _configEmpty
child: _keysEmpty
? const ClipboardIcon()
: const XIcon(),
),
if (_configEmpty)
TextFieldIconButton(
semanticsLabel:
"Scan QR Button. Opens Camera For Scanning QR Code.",
key: const Key("frConfigScanQrButtonKey"),
onTap: () async {
try {
if (FocusScope.of(context).hasFocus) {
FocusScope.of(context).unfocus();
await Future<void>.delayed(
const Duration(milliseconds: 75));
}

final qrResult = await BarcodeScanner.scan();

configFieldController.text =
qrResult.rawContent;

setState(() {
_configEmpty =
configFieldController.text.isEmpty;
});
} on PlatformException catch (e, s) {
Logging.instance.log(
"Failed to get camera permissions while trying to scan qr code: $e\n$s",
level: LogLevel.Warning,
);
}
},
child: const QrCodeIcon(),
)
],
),
),
Expand Down
Loading

0 comments on commit 7b95efa

Please sign in to comment.