Skip to content

Commit

Permalink
Update cloud logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-Stackflow committed Nov 1, 2024
1 parent 622a87e commit cc76523
Show file tree
Hide file tree
Showing 17 changed files with 450 additions and 340 deletions.
18 changes: 17 additions & 1 deletion lib/Screens/Setting/setting_appearance_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class _AppearanceSettingScreenState extends State<AppearanceSettingScreen>
HiveUtil.getBool(HiveUtil.hideBottombarWhenScrollingKey);
final GlobalKey _setAutoBackupPasswordKey = GlobalKey();
bool hideProgressBar = HiveUtil.getBool(HiveUtil.hideProgressBarKey);
bool showEye = HiveUtil.getBool(HiveUtil.showEyeKey);

@override
void initState() {
Expand Down Expand Up @@ -221,6 +222,7 @@ class _AppearanceSettingScreenState extends State<AppearanceSettingScreen>
ItemBuilder.buildRadioItem(
context: context,
title: S.current.showSortButton,
bottomRadius: true,
value: showSortButton,
onTap: () {
setState(() {
Expand All @@ -229,10 +231,11 @@ class _AppearanceSettingScreenState extends State<AppearanceSettingScreen>
});
},
),
const SizedBox(height: 10),
ItemBuilder.buildRadioItem(
context: context,
topRadius: true,
value: hideProgressBar,
bottomRadius: true,
title: S.current.hideProgressBar,
description: S.current.hideProgressBarTip,
onTap: () {
Expand All @@ -242,6 +245,19 @@ class _AppearanceSettingScreenState extends State<AppearanceSettingScreen>
});
},
),
ItemBuilder.buildRadioItem(
context: context,
value: showEye,
bottomRadius: true,
title: S.current.showEye,
description: S.current.showEyeTip,
onTap: () {
setState(() {
showEye = !showEye;
appProvider.showEye = showEye;
});
},
),
];
}

Expand Down
195 changes: 81 additions & 114 deletions lib/Screens/Token/token_layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,61 @@ class TokenLayoutState extends State<TokenLayout>
);
}

_buildVisibleLayout(Function(bool) builder) {
return ChangeNotifierProvider.value(
value: tokenLayoutNotifier,
child: Selector<TokenLayoutNotifier, bool>(
selector: (context, tokenLayoutNotifier) =>
tokenLayoutNotifier.codeVisiable,
builder: (context, codeVisiable, child) => builder(codeVisiable),
),
);
}

_buildVisibleLayoutWithEye(Function(bool) builder) {
return _buildVisibleLayout(
(codeVisiable) => Selector<AppProvider, bool>(
selector: (context, provider) => provider.showEye,
builder: (context, showEye, child) =>
showEye ? builder(codeVisiable) : builder(true),
),
);
}

_buildEyeButton({
double padding = 8,
Color? color,
}) {
return _buildVisibleLayout(
(codeVisiable) {
if (codeVisiable) return emptyWidget;
return Selector<AppProvider, bool>(
selector: (context, provider) => provider.showEye,
builder: (context, showEye, child) => showEye
? Container(
child: ItemBuilder.buildIconButton(
onTap: () {
HapticFeedback.lightImpact();
tokenLayoutNotifier.codeVisiable =
!tokenLayoutNotifier.codeVisiable;
setState(() {});
},
padding: EdgeInsets.all(padding),
icon: Icon(
Icons.visibility_outlined,
size: 20,
color: color ??
Theme.of(context).textTheme.bodyMedium?.color,
),
context: context,
),
)
: emptyWidget,
);
},
);
}

_buildHOTPRefreshButton({
double padding = 8,
Color? color,
Expand Down Expand Up @@ -492,13 +547,10 @@ class TokenLayoutState extends State<TokenLayout>
AlignmentGeometry alignment = Alignment.centerLeft,
bool forceNoType = false,
}) {
return ChangeNotifierProvider.value(
value: tokenLayoutNotifier,
child: Selector<TokenLayoutNotifier, bool>(
selector: (context, tokenLayoutNotifier) =>
tokenLayoutNotifier.codeVisiable,
builder: (context, codeVisiable, child) =>
Selector<TokenLayoutNotifier, String>(
return _buildVisibleLayout(
(codeVisiable) => ChangeNotifierProvider.value(
value: tokenLayoutNotifier,
child: Selector<TokenLayoutNotifier, String>(
selector: (context, tokenLayoutNotifier) => tokenLayoutNotifier.code,
builder: (context, code, child) => Container(
alignment: alignment,
Expand Down Expand Up @@ -552,7 +604,7 @@ class TokenLayoutState extends State<TokenLayout>
: Container(
width: 24,
height: 24,
margin: const EdgeInsets.only(left: 8),
margin: const EdgeInsets.only(left: 8, right: 4),
child: Stack(
children: [
ValueListenableBuilder(
Expand Down Expand Up @@ -602,7 +654,9 @@ class TokenLayoutState extends State<TokenLayout>
}

_processTap() {
tokenLayoutNotifier.codeVisiable = true;
if (!appProvider.showEye) {
tokenLayoutNotifier.codeVisiable = true;
}
updateCode();
if (HiveUtil.getBool(HiveUtil.clickToCopyKey)) {
if (HiveUtil.getBool(HiveUtil.autoCopyNextCodeKey) &&
Expand Down Expand Up @@ -658,6 +712,7 @@ class TokenLayoutState extends State<TokenLayout>
?.apply(fontWeightDelta: 2),
),
),
if (!isHOTP) _buildEyeButton(padding: 6),
if (isHOTP) _buildHOTPRefreshButton(padding: 6),
],
),
Expand Down Expand Up @@ -751,6 +806,11 @@ class TokenLayoutState extends State<TokenLayout>
padding: 4,
color: textTheme.labelSmall?.color,
),
if (!isHOTP)
_buildEyeButton(
padding: 4,
color: textTheme.labelSmall?.color,
),
ItemBuilder.buildIconButton(
context: context,
padding: const EdgeInsets.all(4),
Expand Down Expand Up @@ -780,109 +840,6 @@ class TokenLayoutState extends State<TokenLayout>
);
}

_buildTileLayout() {
return ItemBuilder.buildClickItem(
Material(
color: widget.token.pinned
? Theme.of(context).primaryColor.withOpacity(0.15)
: Theme.of(context).canvasColor,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
clipBehavior: Clip.hardEdge,
child: InkWell(
onTap: _processTap,
borderRadius: BorderRadius.circular(12),
child: Stack(
alignment: Alignment.bottomCenter,
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
),
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Column(
children: [
const SizedBox(height: 12),
Row(
children: [
ItemBuilder.buildTokenImage(widget.token, size: 36),
const SizedBox(width: 8),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
widget.token.issuer,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context)
.textTheme
.titleMedium
?.apply(fontWeightDelta: 2),
),
Text(
widget.token.account,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodySmall,
),
],
),
),
if (isHOTP) _buildHOTPRefreshButton(),
ItemBuilder.buildIconButton(
context: context,
icon: Icon(Icons.edit_rounded,
color: Theme.of(context).iconTheme.color,
size: 20),
onTap: _processEdit),
ItemBuilder.buildIconButton(
context: context,
icon: Icon(Icons.qr_code_rounded,
color: Theme.of(context).iconTheme.color,
size: 20),
onTap: _processViewQrCode),
ItemBuilder.buildIconButton(
context: context,
icon: Icon(Icons.more_vert_rounded,
color: Theme.of(context).iconTheme.color,
size: 20),
onTap: showContextMenu,
),
],
),
const SizedBox(height: 2),
Container(
constraints:
const BoxConstraints(minHeight: 60, maxHeight: 60),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
_buildCodeLayout(fontSize: 28, letterSpacing: 10)
],
),
],
),
),
],
),
),
Selector<AppProvider, bool>(
selector: (context, provider) => provider.hideProgressBar,
builder: (context, hideProgressBar, child) =>
_buildLinearProgress(hideProgressBar),
),
],
),
),
),
);
}

_buildSpotlightLayout() {
return ItemBuilder.buildClickItem(
Material(
Expand Down Expand Up @@ -943,7 +900,11 @@ class TokenLayoutState extends State<TokenLayout>
),
),
const SizedBox(width: 20),
isHOTP ? _buildHOTPRefreshButton() : _buildCircleProgress(),
if (!isHOTP) _buildEyeButton(),
if (isHOTP) _buildHOTPRefreshButton(),
if (!isHOTP)
_buildVisibleLayoutWithEye((codeVisible) =>
codeVisible ? _buildCircleProgress() : emptyWidget),
const SizedBox(width: 2),
],
),
Expand Down Expand Up @@ -983,7 +944,13 @@ class TokenLayoutState extends State<TokenLayout>
),
),
_buildCodeLayout(),
if (!isHOTP) _buildCircleProgress(),
const SizedBox(width: 4),
if (!isHOTP)
_buildEyeButton(
padding: 6, color: Theme.of(context).primaryColor),
if (!isHOTP)
_buildVisibleLayoutWithEye((codeVisible) =>
codeVisible ? _buildCircleProgress() : emptyWidget),
if (isHOTP)
_buildHOTPRefreshButton(
padding: 6, color: Theme.of(context).primaryColor),
Expand Down
2 changes: 1 addition & 1 deletion lib/TokenUtils/Otp/otp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class OTP {

static void _showHOTPWarning(BlockHashBase mac) {
if (mac == sha256 || mac == sha512) {
ILogger.warn("OTP",
ILogger.warning("OTP",
'Using non-SHA1 hashing with HOTP is not part of the RFC for HOTP and may cause incompatibilities between different library implementatiions. This library attempts to match behavior with other libraries as best it can.');
}
}
Expand Down
Loading

0 comments on commit cc76523

Please sign in to comment.