-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Shade
authored and
Shade
committed
Nov 22, 2024
1 parent
0b6887e
commit 8378dd8
Showing
11 changed files
with
190 additions
and
120 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package core.models | ||
|
||
import repository.creditcard.CreditCard | ||
import repository.password.Password | ||
import java.util.* | ||
|
||
data class SelectedCredential( | ||
val password: Password?, | ||
val creditCard: CreditCard? | ||
) { | ||
|
||
fun getTitle(type: DefaultMenuItem): String { | ||
return when(type) { | ||
DefaultMenuItem.PASSWORDS -> { | ||
password?.name?.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } ?: "" | ||
} | ||
|
||
DefaultMenuItem.CREDIT_CARD -> { | ||
creditCard?.name?.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } ?: "" | ||
} | ||
|
||
DefaultMenuItem.NOTES -> TODO() | ||
} | ||
} | ||
|
||
fun getDescription(type: DefaultMenuItem): String { | ||
return when(type) { | ||
DefaultMenuItem.PASSWORDS -> { | ||
password?.email?.takeIf { it.isNotEmpty() } ?: password?.username ?: "" | ||
} | ||
|
||
DefaultMenuItem.CREDIT_CARD -> { | ||
creditCard?.number ?: "" | ||
} | ||
|
||
DefaultMenuItem.NOTES -> TODO() | ||
} | ||
} | ||
|
||
fun isSelected(): Boolean { | ||
return password != null || creditCard != 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.