-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from QuantumPhysique/addBackupReminder
Remember user to frequently backup data, #66
- Loading branch information
Showing
9 changed files
with
343 additions
and
96 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||
|
||
|
||
/// Enum with all available backup intervals | ||
enum BackupInterval { | ||
/// never | ||
never, | ||
/// weekly | ||
weekly, | ||
/// bi-weekly | ||
biweekly, | ||
/// monthly | ||
monthly, | ||
/// quarterly | ||
quarterly, | ||
} | ||
|
||
/// extend interpolation strength | ||
extension BackupIntervalExtension on BackupInterval { | ||
/// get the length [days] | ||
int get inDays => <BackupInterval, int>{ | ||
BackupInterval.never: -1, | ||
BackupInterval.weekly: 7, | ||
BackupInterval.biweekly: 14, | ||
BackupInterval.monthly: 30, | ||
BackupInterval.quarterly: 90, | ||
}[this]!; | ||
|
||
/// get international name | ||
String nameLong (BuildContext context) => <BackupInterval, String>{ | ||
BackupInterval.never: AppLocalizations.of(context)!.never, | ||
BackupInterval.weekly: AppLocalizations.of(context)!.weekly, | ||
BackupInterval.biweekly: AppLocalizations.of(context)!.biweekly, | ||
BackupInterval.monthly: AppLocalizations.of(context)!.monthly, | ||
BackupInterval.quarterly: AppLocalizations.of(context)!.quarterly, | ||
}[this]!; | ||
|
||
/// get string expression | ||
String get name => toString().split('.').last; | ||
} | ||
|
||
/// convert string to interpolation strength | ||
extension BackupIntervalParsing on String { | ||
/// convert string to interpolation strength | ||
BackupInterval? toBackupInterval() { | ||
for (final BackupInterval interval in BackupInterval.values) { | ||
if (this == interval.name) { | ||
return interval; | ||
} | ||
} | ||
return null; | ||
} | ||
} |
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
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.