-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send funds/Wallet details filter tokens by type (Desktop) #171
- Loading branch information
1 parent
33f389c
commit d83d5fc
Showing
11 changed files
with
174 additions
and
43 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
26 changes: 26 additions & 0 deletions
26
common-jvm/src/main/java/org/ergoplatform/uilogic/tokens/FilterTokenListUiLogic.kt
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,26 @@ | ||
package org.ergoplatform.uilogic.tokens | ||
|
||
import org.ergoplatform.persistance.TokenInformation | ||
|
||
/** | ||
* Helper methods for filterable token lists | ||
*/ | ||
interface FilterTokenListUiLogic { | ||
val tokenFilterMap: MutableMap<Int, Boolean> | ||
|
||
fun toggleTokenFilter(filterType: Int) { | ||
tokenFilterMap[filterType] = !(tokenFilterMap[filterType] ?: false) | ||
onFilterChanged() | ||
} | ||
|
||
fun hasTokenFilter(filterType: Int): Boolean = | ||
tokenFilterMap[filterType] ?: false | ||
|
||
fun isTokenInFilter(ti: TokenInformation?): Boolean { | ||
println(tokenFilterMap.values) | ||
return tokenFilterMap.values.none { it } | ||
|| ti?.thumbnailType?.let { tokenFilterMap[it] == true } ?: false | ||
} | ||
|
||
fun onFilterChanged() {} | ||
} |
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
74 changes: 74 additions & 0 deletions
74
desktop/src/main/java/org/ergoplatform/desktop/tokens/TokenFilterMenu.kt
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,74 @@ | ||
package org.ergoplatform.desktop.tokens | ||
|
||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.layout.widthIn | ||
import androidx.compose.material.* | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.Check | ||
import androidx.compose.material.icons.filled.FilterAlt | ||
import androidx.compose.runtime.* | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.alpha | ||
import androidx.compose.ui.unit.dp | ||
import org.ergoplatform.Application | ||
import org.ergoplatform.compose.settings.defaultPadding | ||
import org.ergoplatform.persistance.THUMBNAIL_TYPE_NFT_AUDIO | ||
import org.ergoplatform.persistance.THUMBNAIL_TYPE_NFT_IMG | ||
import org.ergoplatform.persistance.THUMBNAIL_TYPE_NFT_VID | ||
import org.ergoplatform.persistance.THUMBNAIL_TYPE_NONE | ||
import org.ergoplatform.uilogic.STRING_LABEL_TOKEN_AUDIO | ||
import org.ergoplatform.uilogic.STRING_LABEL_TOKEN_GENERIC | ||
import org.ergoplatform.uilogic.STRING_LABEL_TOKEN_IMAGE | ||
import org.ergoplatform.uilogic.STRING_LABEL_TOKEN_VIDEO | ||
import org.ergoplatform.uilogic.tokens.FilterTokenListUiLogic | ||
|
||
@Composable | ||
fun TokenFilterMenu(uiLogic: FilterTokenListUiLogic) { | ||
var showActionMenu by remember { mutableStateOf(false) } | ||
IconButton(onClick = { showActionMenu = !showActionMenu }) { | ||
Icon(Icons.Default.FilterAlt, null) | ||
DropdownMenu( | ||
showActionMenu, | ||
onDismissRequest = { showActionMenu = false }, | ||
modifier = Modifier.widthIn(min = 150.dp) | ||
) { | ||
val modifierForFilter: (Int) -> Modifier = { | ||
Modifier.alpha(if (uiLogic.hasTokenFilter(it)) 1f else 0f) | ||
} | ||
|
||
DropdownMenuItem(onClick = { | ||
uiLogic.toggleTokenFilter(THUMBNAIL_TYPE_NONE) | ||
showActionMenu = false | ||
}) { | ||
Icon(Icons.Default.Check, null, modifierForFilter(THUMBNAIL_TYPE_NONE)) | ||
Spacer(Modifier.size(defaultPadding)) | ||
Text(Application.texts.getString(STRING_LABEL_TOKEN_GENERIC)) | ||
} | ||
DropdownMenuItem(onClick = { | ||
uiLogic.toggleTokenFilter(THUMBNAIL_TYPE_NFT_IMG) | ||
showActionMenu = false | ||
}) { | ||
Icon(Icons.Default.Check, null, modifierForFilter(THUMBNAIL_TYPE_NFT_IMG)) | ||
Spacer(Modifier.size(defaultPadding)) | ||
Text(Application.texts.getString(STRING_LABEL_TOKEN_IMAGE)) | ||
} | ||
DropdownMenuItem(onClick = { | ||
uiLogic.toggleTokenFilter(THUMBNAIL_TYPE_NFT_AUDIO) | ||
showActionMenu = false | ||
}) { | ||
Icon(Icons.Default.Check, null, modifierForFilter(THUMBNAIL_TYPE_NFT_AUDIO)) | ||
Spacer(Modifier.size(defaultPadding)) | ||
Text(Application.texts.getString(STRING_LABEL_TOKEN_AUDIO)) | ||
} | ||
DropdownMenuItem(onClick = { | ||
uiLogic.toggleTokenFilter(THUMBNAIL_TYPE_NFT_VID) | ||
showActionMenu = false | ||
}) { | ||
Icon(Icons.Default.Check, null, modifierForFilter(THUMBNAIL_TYPE_NFT_VID)) | ||
Spacer(Modifier.size(defaultPadding)) | ||
Text(Application.texts.getString(STRING_LABEL_TOKEN_VIDEO)) | ||
} | ||
} | ||
} | ||
} |
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.