Skip to content

Commit

Permalink
[auth] Minor improvements (#3443)
Browse files Browse the repository at this point in the history
## Description

## Tests
  • Loading branch information
ua741 authored Sep 24, 2024
2 parents 14a3f42 + c656a1c commit 6d0f44b
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 27 deletions.
4 changes: 4 additions & 0 deletions auth/lib/models/code.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ class Code {
bool get isPinned => display.pinned;

bool get isTrashed => display.trashed;
String get note => display.note;

final Object? err;
bool get hasError => err != null;

String get issuerAccount =>
account.isNotEmpty ? '$issuer ($account)' : issuer;

Code(
this.account,
this.issuer,
Expand Down
59 changes: 37 additions & 22 deletions auth/lib/ui/components/actions_bar_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,49 @@ class _ActionBarWidgetState extends State<ActionBarWidget> {
return SizedBox(
child: Padding(
padding: const EdgeInsets.fromLTRB(20, 8, 20, 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
child: Column(
// left align the text
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Flexible(
flex: 1,
child: Text(
widget.code.issuer,
if (widget.code.note.isNotEmpty)
SelectableText(
widget.code.note,
style: textTheme.miniMuted,
),
),
Flexible(
flex: 1,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 12),
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
widget.onCancel?.call();
},
child: Align(
alignment: Alignment.centerRight,
child: Text(
context.l10n.cancel,
style: textTheme.mini,
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
flex: 1,
child: Column(
children: [
SelectableText(
widget.code.issuerAccount,
style: textTheme.miniMuted,
),
],
),
),
Flexible(
flex: 1,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 12),
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
widget.onCancel?.call();
},
child: Align(
alignment: Alignment.centerRight,
child: Text(
context.l10n.cancel,
style: textTheme.mini,
),
),
),
),
),
),
],
),
],
),
Expand Down
11 changes: 8 additions & 3 deletions auth/lib/ui/components/bottom_action_bar_widget.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:math';

import 'package:ente_auth/models/code.dart';
import 'package:ente_auth/theme/ente_theme.dart';
import 'package:ente_auth/ui/components/actions_bar_widget.dart';
Expand Down Expand Up @@ -37,9 +39,12 @@ class BottomActionBarWidget extends StatelessWidget {
final bottomPadding = MediaQuery.of(context).padding.bottom;
final widthOfScreen = MediaQuery.of(context).size.width;
final colorScheme = getEnteColorScheme(context);
final double leftRightPadding = widthOfScreen > restrictedMaxWidth
? (widthOfScreen - restrictedMaxWidth) / 2
: 0;
final double leftRightPadding = min(
widthOfScreen > restrictedMaxWidth
? (widthOfScreen - restrictedMaxWidth) / 2
: 0,
20,
);
return Container(
decoration: BoxDecoration(
color: backgroundColor ?? colorScheme.backgroundElevated2,
Expand Down
3 changes: 2 additions & 1 deletion auth/lib/ui/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ class _HomePageState extends State<HomePage> {

return ClipRect(
child: CodeWidget(
key: ValueKey(code.hashCode),
key: ValueKey('${code.hashCode}_$newIndex'),
code,
isCompactMode: isCompactMode,
),
Expand Down Expand Up @@ -493,6 +493,7 @@ class _HomePageState extends State<HomePage> {
itemBuilder: ((context, index) {
final codeState = _filteredCodes[index];
return CodeWidget(
key: ValueKey('${codeState.hashCode}_$index'),
codeState,
isCompactMode: isCompactMode,
);
Expand Down
2 changes: 1 addition & 1 deletion auth/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: ente_auth
description: ente two-factor authenticator
version: 4.0.0+400
version: 4.0.1+401
publish_to: none

environment:
Expand Down

0 comments on commit 6d0f44b

Please sign in to comment.