-
Notifications
You must be signed in to change notification settings - Fork 2
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 #497 from bounswe/feature/mobile-496-add-resource
Implement resource creation
- Loading branch information
Showing
11 changed files
with
297 additions
and
192 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
7 changes: 7 additions & 0 deletions
7
resq/mobile/ResQ/app/src/main/java/com/cmpe451/resq/data/models/CategoryTreeNode.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,7 @@ | ||
package com.cmpe451.resq.data.models | ||
|
||
data class CategoryTreeNode( | ||
val id: Int, | ||
val data: String, | ||
val children: List<CategoryTreeNode> | ||
) |
5 changes: 0 additions & 5 deletions
5
resq/mobile/ResQ/app/src/main/java/com/cmpe451/resq/data/models/Request.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
10 changes: 10 additions & 0 deletions
10
resq/mobile/ResQ/app/src/main/java/com/cmpe451/resq/data/models/Resource.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,10 @@ | ||
package com.cmpe451.resq.data.models | ||
|
||
data class CreateResourceRequestBody( | ||
var senderId: Int?, | ||
val categoryTreeId: String, | ||
val quantity: Int, | ||
val latitude: Double, | ||
val longitude: Double, | ||
val gender: String | ||
) |
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
68 changes: 68 additions & 0 deletions
68
...bile/ResQ/app/src/main/java/com/cmpe451/resq/ui/views/components/DropdownMenuComponent.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,68 @@ | ||
package com.cmpe451.resq.ui.views.components | ||
|
||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.wrapContentWidth | ||
import androidx.compose.material.DropdownMenu | ||
import androidx.compose.material.DropdownMenuItem | ||
import androidx.compose.material.Icon | ||
import androidx.compose.material.OutlinedTextField | ||
import androidx.compose.material.Text | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.KeyboardArrowDown | ||
import androidx.compose.material.icons.filled.KeyboardArrowUp | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
|
||
@Composable | ||
fun <T> DropdownMenuComponent( | ||
label: String, | ||
items: List<T>, | ||
selectedItem: T, | ||
itemToString: (T) -> String, | ||
onItemSelected: (T) -> Unit | ||
) { | ||
var expandState by remember { mutableStateOf(false) } | ||
Box(modifier = Modifier | ||
.fillMaxWidth() | ||
.wrapContentWidth(Alignment.Start) | ||
) { | ||
OutlinedTextField( | ||
value = itemToString(selectedItem), | ||
onValueChange = {}, | ||
label = { Text(label) }, | ||
readOnly = true, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.clickable { expandState = true }, | ||
trailingIcon = { | ||
Icon( | ||
imageVector = if (expandState) Icons.Filled.KeyboardArrowUp else Icons.Filled.KeyboardArrowDown, | ||
contentDescription = "Dropdown Icon", | ||
modifier = Modifier.clickable { expandState = !expandState } | ||
) | ||
} | ||
) | ||
DropdownMenu( | ||
expanded = expandState, | ||
onDismissRequest = { expandState = false }, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
) { | ||
items.forEach { item -> | ||
DropdownMenuItem(onClick = { | ||
onItemSelected(item) | ||
expandState = false | ||
}) { | ||
Text(text = itemToString(item)) | ||
} | ||
} | ||
} | ||
} | ||
} |
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.