|
|
|
@ -2,13 +2,16 @@ package com.example.what_the_fantasy.ui.screens
|
|
|
|
|
|
|
|
|
|
import androidx.compose.foundation.background
|
|
|
|
|
import androidx.compose.foundation.clickable
|
|
|
|
|
import androidx.compose.foundation.gestures.scrollable
|
|
|
|
|
import androidx.compose.foundation.layout.Box
|
|
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
|
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
|
|
import androidx.compose.foundation.rememberScrollState
|
|
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
|
|
import androidx.compose.foundation.text.KeyboardOptions
|
|
|
|
|
import androidx.compose.foundation.verticalScroll
|
|
|
|
|
import androidx.compose.material3.Button
|
|
|
|
|
import androidx.compose.material3.ButtonDefaults
|
|
|
|
|
import androidx.compose.material3.OutlinedTextField
|
|
|
|
@ -53,7 +56,8 @@ fun SubmitQuotePage(
|
|
|
|
|
Box(
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.fillMaxSize()
|
|
|
|
|
.background(colorBackground),
|
|
|
|
|
.background(colorBackground)
|
|
|
|
|
.verticalScroll(rememberScrollState()),
|
|
|
|
|
contentAlignment = Alignment.Center
|
|
|
|
|
){
|
|
|
|
|
Column(
|
|
|
|
@ -229,12 +233,18 @@ fun goToRecap(quote: String,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun validSubmitQuote(quote : String, character : String, source: String, timeCode: String, year: String): Boolean{
|
|
|
|
|
val isNotBlank = quote.isNotBlank() &&
|
|
|
|
|
character.isNotBlank() &&
|
|
|
|
|
source.isNotBlank() &&
|
|
|
|
|
timeCode.isNotBlank() &&
|
|
|
|
|
year.isNotBlank() &&
|
|
|
|
|
year.all { it.isDigit() }
|
|
|
|
|
|
|
|
|
|
val quoteRegex = """^[A-Za-zÀ-ÿ0-9\s\-\.,!?'"()]+$""".toRegex()
|
|
|
|
|
val timeCodeRegex = """^\d{1}:\d{2}:\d{2}$""".toRegex()
|
|
|
|
|
val movieTitleRegex = """^[A-Za-z0-9\s\-\(\):]+$""".toRegex()
|
|
|
|
|
val characterRegex = """^[A-Za-zÀ-ÿ\s\-']+$""".toRegex()
|
|
|
|
|
val invalidRegex = """^[a-zA-Z0-9]*$""".toRegex()
|
|
|
|
|
|
|
|
|
|
val isNotBlank = quote.isNotBlank() && quote.matches(quoteRegex) && !quote.matches(invalidRegex) && quote.length in 3..100 &&
|
|
|
|
|
character.isNotBlank() && character.matches(characterRegex) && character.length in 3..50 && !character.matches(invalidRegex) &&
|
|
|
|
|
source.isNotBlank() && source.matches(movieTitleRegex) && source.length in 3..50 && !source.matches(invalidRegex) &&
|
|
|
|
|
timeCode.isNotBlank() && timeCode.matches(timeCodeRegex) &&
|
|
|
|
|
year.isNotBlank() && year.all { it.isDigit() } && year.length == 4 && year.toInt() in 1900..2025
|
|
|
|
|
return isNotBlank
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|