Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.cornellappdev.resell.android.model.api

import com.google.gson.annotations.SerializedName
import retrofit2.http.Body
import retrofit2.http.POST

interface FeedbackApiService {
@POST("feedback")
suspend fun sendFeedback(@Body reportBody: FeedbackBody): FeedbackBody

@POST("feedback/search")
suspend fun searchFeedback(@Body reportBody : SearchFeedback): SearchFeedback
}

data class FeedbackBody(
val userId: String,
val content: String
)

data class SearchFeedback(
val query: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ class RetrofitInstance @Inject constructor(
.create(SettingsApiService::class.java)
}

val feedbackApi: FeedbackApiService by lazy {
Retrofit.Builder()
.baseUrl(BuildConfig.BASE_API_URL)
.client(okHttpClient)
.addConverterFactory(GsonConverterFactory.create())
.build()
.create(FeedbackApiService::class.java)
}

val notificationsApi: FcmApiService by lazy {
Retrofit.Builder()
.baseUrl(BuildConfig.FCM_URL)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.cornellappdev.resell.android.model.settings

import com.cornellappdev.resell.android.model.api.FeedbackBody
import com.cornellappdev.resell.android.model.api.RetrofitInstance
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class FeedbackRepository @Inject constructor(
private val retrofitInstance: RetrofitInstance
) {
suspend fun sendFeedback(uid: String, content: String) {
retrofitInstance.feedbackApi.sendFeedback(
FeedbackBody(
userId = uid,
content = content
)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
Expand All @@ -14,9 +15,11 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import com.cornellappdev.resell.android.R
import com.cornellappdev.resell.android.ui.components.global.ResellHeader
import com.cornellappdev.resell.android.ui.components.global.ResellTextButton
import com.cornellappdev.resell.android.ui.components.global.ResellTextEntry
Expand All @@ -32,8 +35,8 @@ fun ReportDetailsScreen(
) {
val uiState = reportDetailsViewModel.collectUiStateValue()

Box(
modifier = Modifier.fillMaxSize()
Column(
modifier = Modifier.fillMaxSize(),
) {
Content(
title = uiState.title,
Expand All @@ -43,16 +46,17 @@ fun ReportDetailsScreen(
onDetailsChanged = reportDetailsViewModel::onTypedContentChanged,
)

ResellTextButton(
text = "Submit",
state = uiState.buttonState,
onClick = {
reportDetailsViewModel.onSubmitPressed()
},
modifier = Modifier
.align(Alignment.BottomCenter)
.padding(bottom = 46.dp)
)
Column(horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier.fillMaxSize()) {
ResellTextButton(
text = "Submit",
state = uiState.buttonState,
onClick = {
reportDetailsViewModel.onSubmitPressed()
},
modifier = Modifier
.padding(bottom = 46.dp)
)
}
}
}

Expand All @@ -67,43 +71,37 @@ private fun Content(
) {
Column(
modifier = Modifier
.fillMaxSize()
.fillMaxWidth()
.background(Color.White)
.verticalScroll(rememberScrollState()),
horizontalAlignment = Alignment.CenterHorizontally
) {
ResellHeader(
title = title,
leftPainter = R.drawable.ic_chevron_left
)

Column(modifier = Modifier.defaultHorizontalPadding().padding(vertical = 36.dp)) {
Text(
text = "Explain what happened: ",
style = title1,
)

Spacer(Modifier.height(24.dp))
Spacer(Modifier.height(16.dp))

Text(
text = subtitle,
style = title1,
)
ResellTextEntry(
text = details,
onTextChange = onDetailsChanged,
inlineLabel = false,
multiLineHeight = 205.dp,
singleLine = false,
// TODO: probably wrong max lines
maxLines = 20,
placeholder = body,
textFontStyle = body2,
)

Spacer(Modifier.height(16.dp))
}

Text(
text = body,
style = body2,
color = AppDev,
)

Spacer(Modifier.height(8.dp))

// TODO Incorrect text entry design
ResellTextEntry(
text = details,
onTextChange = onDetailsChanged,
inlineLabel = false,
multiLineHeight = 255.dp,
singleLine = false,
// TODO: probably wrong max lines
maxLines = 20,
modifier = Modifier.defaultHorizontalPadding(),
placeholder = "enter feedback details..."
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.cornellappdev.resell.android.viewmodel.navigation.ReportNavigationViewModel
import com.cornellappdev.resell.android.viewmodel.report.ReportType
import kotlinx.serialization.Serializable

@Composable
Expand All @@ -27,7 +28,7 @@ fun ReportNavigation(
NavHost(
navController = navController,
startDestination = uiState.initialPage ?: ReportScreen.Reason(
reportPost = true,
reportType = ReportType.POST,
postId = "",
userId = ""
),
Expand All @@ -51,22 +52,22 @@ fun ReportNavigation(
sealed class ReportScreen {
@Serializable
data class Reason(
val reportPost: Boolean,
val reportType: ReportType,
val postId: String,
val userId: String
) : ReportScreen()

@Serializable
data class Details(
val reportPost: Boolean,
val reportType: ReportType,
val postId: String,
val userId: String,
val reason: String,
) : ReportScreen()

@Serializable
data class Confirmation(
val reportPost: Boolean,
val reportType: ReportType,
val userId: String,
) : ReportScreen()
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import com.cornellappdev.resell.android.ui.screens.onboarding.OnboardingNavigati
import com.cornellappdev.resell.android.ui.screens.pdp.PostDetailPage
import com.cornellappdev.resell.android.ui.screens.reporting.ReportNavigation
import com.cornellappdev.resell.android.ui.screens.settings.SettingsNavigation
import com.cornellappdev.resell.android.viewmodel.report.ReportType
import com.cornellappdev.resell.android.viewmodel.root.RootNavigationViewModel
import com.cornellappdev.resell.android.viewmodel.root.RootSheet
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -232,7 +233,7 @@ sealed class ResellRootRoute {

@Serializable
data class REPORT(
val reportPost: Boolean,
val reportType: ReportType,
val postId: String,
val userId: String
) : ResellRootRoute()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.cornellappdev.resell.android.ui.screens.externalprofile.ExternalProfi
import com.cornellappdev.resell.android.ui.screens.root.ResellRootRoute
import com.cornellappdev.resell.android.viewmodel.ResellViewModel
import com.cornellappdev.resell.android.viewmodel.navigation.RootNavigationRepository
import com.cornellappdev.resell.android.viewmodel.report.ReportType
import com.cornellappdev.resell.android.viewmodel.root.OptionType
import com.cornellappdev.resell.android.viewmodel.root.RootConfirmationRepository
import com.cornellappdev.resell.android.viewmodel.root.RootDialogRepository
Expand Down Expand Up @@ -98,7 +99,7 @@ class ExternalProfileViewModel @Inject constructor(
OptionType.REPORT -> {
rootNavigationRepository.navigate(
ResellRootRoute.REPORT(
reportPost = false,
reportType = ReportType.USER,
postId = "",
userId = stateValue().uid,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ReportNavigationViewModel @Inject constructor(
applyMutation {
copy(
initialPage = ReportScreen.Reason(
reportPost = navArgs.reportPost,
reportType = navArgs.reportType,
postId = navArgs.postId,
userId = navArgs.userId
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.cornellappdev.resell.android.util.UIEvent
import com.cornellappdev.resell.android.util.richieUrl
import com.cornellappdev.resell.android.viewmodel.ResellViewModel
import com.cornellappdev.resell.android.viewmodel.navigation.RootNavigationRepository
import com.cornellappdev.resell.android.viewmodel.report.ReportType
import com.cornellappdev.resell.android.viewmodel.root.OptionType
import com.cornellappdev.resell.android.viewmodel.root.RootConfirmationRepository
import com.cornellappdev.resell.android.viewmodel.root.RootDialogContent
Expand Down Expand Up @@ -185,7 +186,7 @@ class PostDetailViewModel @Inject constructor(
OptionType.REPORT -> {
rootNavigationRepository.navigate(
ResellRootRoute.REPORT(
reportPost = true,
reportType = ReportType.POST,
postId = stateValue().postId,
userId = stateValue().uid,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.cornellappdev.resell.android.viewmodel.report
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.viewModelScope
import androidx.navigation.toRoute
import com.cornellappdev.resell.android.model.api.Report
import com.cornellappdev.resell.android.model.classes.ResellApiResponse
import com.cornellappdev.resell.android.model.profile.ProfileRepository
import com.cornellappdev.resell.android.model.settings.BlockedUsersRepository
Expand All @@ -27,33 +28,33 @@ class ReportConfirmationViewModel @Inject constructor(
) :
ResellViewModel<ReportConfirmationViewModel.ConfirmationUiState>(
initialUiState = ConfirmationUiState(
reportPost = true,
reportType = ReportType.POST,
userId = ""
)
) {


data class ConfirmationUiState(
private val reportPost: Boolean,
private val reportType: ReportType,
val userId: String,
val accountName: ResellApiResponse<String> = ResellApiResponse.Pending
) {
val headerTitle: String
get() = if (reportPost) {
"Report Post"
} else {
"Report Account"
get() = when(reportType) {
ReportType.POST -> "Report Post"
ReportType.USER -> "Report Account"
ReportType.POST_TRANSACTION -> "Report Transaction"
}

val title: String
get() = if (reportPost) {
"Thank you for reporting this post"
} else {
"Thank you for reporting this account"
get() = when(reportType) {
ReportType.POST -> "Thank you for reporting this post"
ReportType.USER -> "Thank you for reporting this account"
ReportType.POST_TRANSACTION -> "Thank you for reporting this transaction"
}

val body: String
get() = "Your report is valued in keeping Resell a safe community. We will be carefully reviewing the ${if (reportPost) "post" else "account"} and taking any necessary action."
get() = "Your report is valued in keeping Resell a safe community. We will be carefully reviewing the information and taking any necessary action." //TODO CHECK W DESIGN

val blockText: String
get() = if (accountName is ResellApiResponse.Success) "Block ${accountName.data}?" else "Block Account?"
Expand Down Expand Up @@ -101,7 +102,7 @@ class ReportConfirmationViewModel @Inject constructor(

applyMutation {
copy(
reportPost = navArgs.reportPost,
reportType = navArgs.reportType,
userId = navArgs.userId
)
}
Expand Down
Loading