Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
Kaffeekasse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonas Broeckmann
Kaffeekasse
Commits
88a29775
Commit
88a29775
authored
1 week ago
by
Jonas Broeckmann
Browse files
Options
Downloads
Patches
Plain Diff
Improve device logout confirmation flow
parent
71ddc989
No related branches found
No related tags found
No related merge requests found
Pipeline
#1654583
failed
1 week ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/main/java/net/novagamestudios/kaffeekasse/ui/login/LoginDevice.kt
+105
-12
105 additions, 12 deletions
...a/net/novagamestudios/kaffeekasse/ui/login/LoginDevice.kt
with
105 additions
and
12 deletions
app/src/main/java/net/novagamestudios/kaffeekasse/ui/login/LoginDevice.kt
+
105
−
12
View file @
88a29775
...
...
@@ -335,19 +335,112 @@ private fun ConfirmLogoutDeviceDialog(
onDismiss
:
()
->
Unit
,
onConfirm
:
()
->
Unit
,
modifier
:
Modifier
=
Modifier
)
=
AlertDialog
(
onDismissRequest
=
onDismiss
,
confirmButton
=
{
Button
(
onClick
=
onConfirm
)
{
Text
(
"Ausloggen"
)
}
},
modifier
,
dismissButton
=
{
TextButton
(
onClick
=
onDismiss
)
{
Text
(
"Abbrechen"
)
}
},
text
=
{
Text
(
"Möchtest du das Gerät wirklich ausloggen?"
)
)
{
val
toasts
=
remember
{
ToastsState
()
}
Toasts
(
toasts
)
val
target
=
42
val
minSolution
=
-
10
val
maxSolution
=
10
fun
newRandomEquation
()
=
randomEquation
(
target
=
target
,
minSolution
=
minSolution
,
maxSolution
=
maxSolution
)
var
equationAndSolution
by
remember
{
mutableStateOf
(
newRandomEquation
())
}
)
val
(
equation
,
solution
)
=
equationAndSolution
var
userAnswer
by
remember
{
mutableStateOf
<
Float
?>(
null
)
}
var
userAnswerIncorrect
by
remember
{
mutableStateOf
(
false
)
}
fun
submitUserAnswer
()
{
if
(
userAnswer
?.
toInt
()
==
solution
)
{
onConfirm
()
}
else
{
userAnswerIncorrect
=
true
}
}
AlertDialog
(
onDismissRequest
=
onDismiss
,
confirmButton
=
{
Button
(
onClick
=
{
submitUserAnswer
()
},
enabled
=
userAnswer
!=
null
)
{
Text
(
"Ausloggen"
)
}
},
modifier
,
dismissButton
=
{
TextButton
(
onClick
=
onDismiss
)
{
Text
(
"Abbrechen"
)
}
},
icon
=
{
Icon
(
Icons
.
Rounded
.
Warning
,
"Achtung"
)
},
title
=
{
Text
(
"Gerät wirklich ausloggen?"
)
},
text
=
{
ColumnCenter
(
Modifier
.
width
(
IntrinsicSize
.
Max
))
{
Text
(
"Bitte löse die folgende Gleichung, um fortzufahren:"
)
Box
(
Modifier
.
fillMaxWidth
())
{
Text
(
text
=
equation
,
modifier
=
Modifier
.
padding
(
24
.
dp
).
align
(
Alignment
.
Center
),
style
=
MaterialTheme
.
typography
.
titleMedium
.
copy
(
fontFamily
=
FontFamily
.
Serif
)
)
IconButton
(
onClick
=
{
equationAndSolution
=
newRandomEquation
()
userAnswer
=
null
userAnswerIncorrect
=
false
},
modifier
=
Modifier
.
align
(
Alignment
.
CenterEnd
)
)
{
Icon
(
Icons
.
Default
.
Refresh
,
"Neue Gleichung"
)
}
}
var
currentInput
by
remember
{
mutableStateOf
(
""
)
}
LaunchedEffect
(
userAnswer
)
{
if
(
currentInput
.
toIntOrNull
()
!=
userAnswer
?.
toInt
())
{
currentInput
=
"${userAnswer?.toInt() ?: ""}"
}
}
OutlinedTextField
(
value
=
currentInput
,
onValueChange
=
{
val
sanitized
=
it
.
filter
{
c
->
c
.
isDigit
()
||
c
in
setOf
(
'-'
,
'+'
,
'.'
,
','
)
}
currentInput
=
sanitized
userAnswer
=
sanitized
.
toIntOrNull
()
?.
toFloat
()
userAnswerIncorrect
=
false
},
modifier
=
Modifier
.
defaultMinSize
(
minWidth
=
1
.
dp
),
textStyle
=
LocalTextStyle
.
current
.
copy
(
fontFamily
=
FontFamily
.
Serif
),
placeholder
=
{
Text
(
"?"
)
},
prefix
=
{
Text
(
"x = "
,
fontFamily
=
FontFamily
.
Serif
)
},
isError
=
userAnswerIncorrect
||
(
currentInput
.
isNotEmpty
()
&&
userAnswer
==
null
),
keyboardOptions
=
KeyboardOptions
(
keyboardType
=
KeyboardType
.
Number
,
imeAction
=
ImeAction
.
Done
),
keyboardActions
=
KeyboardActions
(
onDone
=
{
submitUserAnswer
()
})
)
}
},
iconContentColor
=
MaterialTheme
.
colorScheme
.
error
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment