-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TF-3219 display limits of email recovery in a yellow banner and filte…
…r out invalid suggestions
- Loading branch information
1 parent
5094fd4
commit aa99995
Showing
15 changed files
with
270 additions
and
13 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
42 changes: 42 additions & 0 deletions
42
lib/features/email_recovery/presentation/model/session_extension.dart
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,42 @@ | ||
|
||
import 'package:duration/duration.dart'; | ||
import 'package:email_recovery/email_recovery/capability_deleted_messages_vault.dart'; | ||
import 'package:jmap_dart_client/jmap/core/session/session.dart'; | ||
import 'package:model/extensions/session_extension.dart'; | ||
|
||
extension SessionExtension on Session { | ||
|
||
String getRestorationHorizonAsString() { | ||
String restorationHorizon = 'restorationHorizon'; | ||
String defaultHorizon = "15 days"; | ||
|
||
return (getCapabilityProperties(accountId, capabilityDeletedMessagesVault) | ||
?.props[0] as Map<String, dynamic>?) | ||
?[restorationHorizon] | ||
?? defaultHorizon; | ||
} | ||
|
||
Duration getRestorationHorizonAsDuration() { | ||
try { | ||
String horizonWithCorrectFormat = getRestorationHorizonAsString() | ||
.replaceAll(" days", "d") | ||
.replaceAll(" day", "d") | ||
.replaceAll(" hours", "h") | ||
.replaceAll(" hour", "h") | ||
.replaceAll(" minutes", "m") | ||
.replaceAll(" minute", "m") | ||
.replaceAll(" seconds", "s") | ||
.replaceAll(" second", "s") | ||
.replaceAll(" milliseconds", "ms") | ||
.replaceAll(" millisecond", "ms"); | ||
|
||
return parseDuration(horizonWithCorrectFormat, separator: ' '); | ||
} catch (e) { | ||
return const Duration(days: 15); | ||
} | ||
} | ||
|
||
DateTime getRestorationHorizonAsDateTime() { | ||
return DateTime.now().subtract(getRestorationHorizonAsDuration()); | ||
} | ||
} |
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
33 changes: 33 additions & 0 deletions
33
lib/features/email_recovery/presentation/widgets/limits_banner.dart
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,33 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class LimitsBanner extends StatelessWidget { | ||
final String bannerContent; | ||
|
||
const LimitsBanner({ | ||
super.key, | ||
required this.bannerContent, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Container( | ||
width: double.infinity, | ||
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0), | ||
decoration: BoxDecoration( | ||
color: Colors.yellow[400], | ||
borderRadius: const BorderRadius.all(Radius.circular(8.0)), | ||
), | ||
child: Center( | ||
child: Text( | ||
bannerContent, | ||
style: const TextStyle( | ||
fontSize: 16, | ||
color: Colors.black, | ||
fontWeight: FontWeight.bold, | ||
), | ||
textAlign: TextAlign.center, | ||
), | ||
), | ||
); | ||
} | ||
} |
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
Oops, something went wrong.