Animate OATH code view resizes.

This commit is contained in:
Dain Nilsson 2022-04-05 15:23:51 +02:00
parent ba2e5be021
commit daba41bbfd
No known key found for this signature in database
GPG Key ID: F04367096FBA95E8
2 changed files with 77 additions and 68 deletions

View File

@ -81,40 +81,45 @@ class AccountDialog extends ConsumerWidget with AccountMixin {
borderRadius: const BorderRadius.all(Radius.circular(30.0)),
border: Border.all(width: 1.0, color: Colors.grey.shade500),
),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16.0, vertical: 8.0),
child: Row(
mainAxisSize: MainAxisSize.min,
children: code == null
? [
const Icon(Icons.touch_app, size: 36),
const Text('', style: TextStyle(fontSize: 32.0)),
]
: [
if (credential.oathType == OathType.totp) ...[
credential.touchRequired && expired
? const Icon(Icons.touch_app)
: SizedBox.square(
dimension: 32,
child: CircleTimer(
code.validFrom * 1000,
code.validTo * 1000,
child: AnimatedSize(
duration: const Duration(milliseconds: 100),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16.0, vertical: 8.0),
child: Row(
mainAxisSize: MainAxisSize.min,
children: code == null
? [
const Icon(Icons.touch_app, size: 36),
const Text('', style: TextStyle(fontSize: 32.0)),
]
: [
if (credential.oathType == OathType.totp) ...[
credential.touchRequired && expired
? const Icon(Icons.touch_app)
: SizedBox.square(
dimension: 32,
child: CircleTimer(
code.validFrom * 1000,
code.validTo * 1000,
),
),
),
const SizedBox(width: 8.0)
],
Opacity(
opacity: expired ? 0.4 : 1.0,
child: Text(
formatCode(code),
style: const TextStyle(
fontSize: 32.0,
fontFeatures: [FontFeature.tabularFigures()],
const SizedBox(width: 8.0)
],
Opacity(
opacity: expired ? 0.4 : 1.0,
child: Text(
formatCode(code),
style: const TextStyle(
fontSize: 32.0,
fontFeatures: [
FontFeature.tabularFigures()
],
),
),
),
),
],
],
),
),
),
),

View File

@ -139,46 +139,50 @@ class AccountView extends ConsumerWidget with AccountMixin {
borderRadius: const BorderRadius.all(Radius.circular(30.0)),
border: Border.all(width: 1.0, color: Colors.grey.shade500),
),
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 10.0, vertical: 2.0),
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: code == null
? [
Icon(
credential.oathType == OathType.hotp
? Icons.refresh
: Icons.touch_app,
size: 18,
),
const Text('', style: TextStyle(fontSize: 22.0)),
]
: [
if (credential.oathType == OathType.totp) ...[
credential.touchRequired && expired
? const Icon(Icons.touch_app)
: SizedBox.square(
dimension: 16,
child: CircleTimer(
code.validFrom * 1000,
code.validTo * 1000,
),
child: AnimatedSize(
duration: const Duration(milliseconds: 100),
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 10.0, vertical: 2.0),
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: code == null
? [
Icon(
credential.oathType == OathType.hotp
? Icons.refresh
: Icons.touch_app,
size: 18,
),
const Text('', style: TextStyle(fontSize: 22.0)),
]
: [
if (credential.oathType == OathType.totp) ...[
if (credential.touchRequired && expired)
const Icon(Icons.touch_app),
if (!expired)
SizedBox.square(
dimension: 16,
child: CircleTimer(
code.validFrom * 1000,
code.validTo * 1000,
),
const SizedBox(width: 8.0)
],
Opacity(
opacity: expired ? 0.4 : 1.0,
child: Text(
formatCode(code),
style: const TextStyle(
fontSize: 22.0,
fontFeatures: [FontFeature.tabularFigures()],
),
const SizedBox(width: 8.0)
],
Opacity(
opacity: expired ? 0.4 : 1.0,
child: Text(
formatCode(code),
style: const TextStyle(
fontSize: 22.0,
fontFeatures: [FontFeature.tabularFigures()],
),
),
),
),
],
],
),
),
),
),