mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2025-03-14 09:45:42 +00:00
ui: fix "View conditions" view on onboarding offering to accept conditions when no operators are selected (#5710)
* ios: fix "View conditions" view on onboarding * kotlin
This commit is contained in:
parent
257208a99b
commit
3425bd0826
8 changed files with 66 additions and 52 deletions
|
@ -303,8 +303,7 @@ struct ContentView: View {
|
|||
case .updatedConditions:
|
||||
UsageConditionsView(
|
||||
currUserServers: Binding.constant([]),
|
||||
userServers: Binding.constant([]),
|
||||
updated: true
|
||||
userServers: Binding.constant([])
|
||||
)
|
||||
.modifier(ThemedBackground(grouped: true))
|
||||
.task { await setConditionsNotified_() }
|
||||
|
|
|
@ -161,12 +161,8 @@ struct ChooseServerOperators: View {
|
|||
case .showInfo:
|
||||
ChooseServerOperatorsInfoView()
|
||||
case .showConditions:
|
||||
UsageConditionsView(
|
||||
currUserServers: Binding.constant([]),
|
||||
userServers: Binding.constant([]),
|
||||
updated: false
|
||||
)
|
||||
.modifier(ThemedBackground(grouped: true))
|
||||
SimpleConditionsView()
|
||||
.modifier(ThemedBackground(grouped: true))
|
||||
}
|
||||
}
|
||||
.frame(maxHeight: .infinity, alignment: .top)
|
||||
|
|
|
@ -647,8 +647,7 @@ struct WhatsNewView: View {
|
|||
case .showConditions:
|
||||
UsageConditionsView(
|
||||
currUserServers: Binding.constant([]),
|
||||
userServers: Binding.constant([]),
|
||||
updated: true
|
||||
userServers: Binding.constant([])
|
||||
)
|
||||
.modifier(ThemedBackground(grouped: true))
|
||||
}
|
||||
|
|
|
@ -20,11 +20,11 @@ private enum NetworkAlert: Identifiable {
|
|||
}
|
||||
|
||||
private enum NetworkAndServersSheet: Identifiable {
|
||||
case showConditions(updated: Bool)
|
||||
case showConditions
|
||||
|
||||
var id: String {
|
||||
switch self {
|
||||
case let .showConditions(updated): return "showConditions \(updated)"
|
||||
case .showConditions: return "showConditions"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -169,11 +169,10 @@ struct NetworkAndServers: View {
|
|||
}
|
||||
.sheet(item: $sheetItem) { item in
|
||||
switch item {
|
||||
case let .showConditions(updated):
|
||||
case .showConditions:
|
||||
UsageConditionsView(
|
||||
currUserServers: $ss.servers.currUserServers,
|
||||
userServers: $ss.servers.userServers,
|
||||
updated: updated
|
||||
userServers: $ss.servers.userServers
|
||||
)
|
||||
.modifier(ThemedBackground(grouped: true))
|
||||
}
|
||||
|
@ -219,8 +218,7 @@ struct NetworkAndServers: View {
|
|||
|
||||
private func conditionsButton(_ conditionsAction: UsageConditionsAction) -> some View {
|
||||
Button {
|
||||
let updated = if case .review = conditionsAction { true } else { false }
|
||||
sheetItem = .showConditions(updated: updated)
|
||||
sheetItem = .showConditions
|
||||
} label: {
|
||||
switch conditionsAction {
|
||||
case .review:
|
||||
|
@ -237,30 +235,26 @@ struct UsageConditionsView: View {
|
|||
@EnvironmentObject var theme: AppTheme
|
||||
@Binding var currUserServers: [UserOperatorServers]
|
||||
@Binding var userServers: [UserOperatorServers]
|
||||
var updated: Bool
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 20) {
|
||||
HStack {
|
||||
if updated {
|
||||
Text("Updated conditions").font(.largeTitle).bold()
|
||||
} else {
|
||||
Text("Conditions of use").font(.largeTitle).bold()
|
||||
Spacer()
|
||||
conditionsLinkButton()
|
||||
}
|
||||
}
|
||||
.padding(.top)
|
||||
.padding(.top)
|
||||
|
||||
switch ChatModel.shared.conditions.conditionsAction {
|
||||
|
||||
case .none:
|
||||
regularConditionsHeader()
|
||||
.padding(.top)
|
||||
.padding(.top)
|
||||
ConditionsTextView()
|
||||
.padding(.bottom)
|
||||
.padding(.bottom)
|
||||
|
||||
case let .review(operators, deadline, _):
|
||||
HStack {
|
||||
Text("Updated conditions").font(.largeTitle).bold()
|
||||
}
|
||||
.padding(.top)
|
||||
.padding(.top)
|
||||
|
||||
Text("Conditions will be accepted for the operator(s): **\(operators.map { $0.legalName_ }.joined(separator: ", "))**.")
|
||||
ConditionsTextView()
|
||||
VStack(spacing: 8) {
|
||||
|
@ -272,10 +266,8 @@ struct UsageConditionsView: View {
|
|||
.multilineTextAlignment(.center)
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
.padding(.horizontal, 32)
|
||||
if updated {
|
||||
conditionsDiffButton(.footnote)
|
||||
}
|
||||
} else if updated {
|
||||
conditionsDiffButton(.footnote)
|
||||
} else {
|
||||
conditionsDiffButton()
|
||||
.padding(.top)
|
||||
}
|
||||
|
@ -285,6 +277,9 @@ struct UsageConditionsView: View {
|
|||
|
||||
|
||||
case let .accepted(operators):
|
||||
regularConditionsHeader()
|
||||
.padding(.top)
|
||||
.padding(.top)
|
||||
Text("Conditions are accepted for the operator(s): **\(operators.map { $0.legalName_ }.joined(separator: ", "))**.")
|
||||
ConditionsTextView()
|
||||
.padding(.bottom)
|
||||
|
@ -340,6 +335,30 @@ struct UsageConditionsView: View {
|
|||
}
|
||||
}
|
||||
|
||||
private func regularConditionsHeader() -> some View {
|
||||
HStack {
|
||||
Text("Conditions of use").font(.largeTitle).bold()
|
||||
Spacer()
|
||||
conditionsLinkButton()
|
||||
}
|
||||
}
|
||||
|
||||
struct SimpleConditionsView: View {
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 20) {
|
||||
regularConditionsHeader()
|
||||
.padding(.top)
|
||||
.padding(.top)
|
||||
ConditionsTextView()
|
||||
.padding(.bottom)
|
||||
.padding(.bottom)
|
||||
}
|
||||
.padding(.horizontal, 25)
|
||||
.frame(maxHeight: .infinity)
|
||||
}
|
||||
}
|
||||
|
||||
func validateServers_(_ userServers: Binding<[UserOperatorServers]>, _ serverErrors: Binding<[UserServersError]>) {
|
||||
let userServersToValidate = userServers.wrappedValue
|
||||
Task {
|
||||
|
|
|
@ -148,7 +148,6 @@ fun ChatListView(chatModel: ChatModel, userPickerState: MutableStateFlow<Animate
|
|||
UsageConditionsView(
|
||||
userServers = mutableStateOf(emptyList()),
|
||||
currUserServers = mutableStateOf(emptyList()),
|
||||
updated = true,
|
||||
close = close,
|
||||
rhId = rhId
|
||||
)
|
||||
|
|
|
@ -91,13 +91,7 @@ fun ModalData.ChooseServerOperators(
|
|||
if (onboarding && reviewForOperators.isEmpty()) {
|
||||
TextButtonBelowOnboardingButton(stringResource(MR.strings.operator_conditions_of_use)) {
|
||||
modalManager.showModalCloseable(endButtons = { ConditionsLinkButton() }) { close ->
|
||||
UsageConditionsView(
|
||||
currUserServers = remember { mutableStateOf(emptyList()) },
|
||||
userServers = remember { mutableStateOf(emptyList()) },
|
||||
updated = false,
|
||||
close = close,
|
||||
rhId = null,
|
||||
)
|
||||
SimpleConditionsView(rhId = null)
|
||||
}
|
||||
}
|
||||
} else if (onboarding || reviewForOperators.isEmpty()) {
|
||||
|
|
|
@ -169,7 +169,6 @@ fun ModalData.WhatsNewView(updatedConditions: Boolean = false, viaSettings: Bool
|
|||
UsageConditionsView(
|
||||
userServers = mutableStateOf(emptyList()),
|
||||
currUserServers = mutableStateOf(emptyList()),
|
||||
updated = true,
|
||||
close = close,
|
||||
rhId = rhId
|
||||
)
|
||||
|
|
|
@ -188,7 +188,6 @@ fun ModalData.NetworkAndServersView(closeNetworkAndServers: () -> Unit) {
|
|||
UsageConditionsView(
|
||||
currUserServers,
|
||||
userServers,
|
||||
updated = conditionsAction is UsageConditionsAction.Review,
|
||||
close,
|
||||
rhId
|
||||
)
|
||||
|
@ -712,7 +711,6 @@ private fun UnsavedChangesIndicator() {
|
|||
fun UsageConditionsView(
|
||||
currUserServers: MutableState<List<UserOperatorServers>>,
|
||||
userServers: MutableState<List<UserOperatorServers>>,
|
||||
updated: Boolean,
|
||||
close: () -> Unit,
|
||||
rhId: Long?
|
||||
) {
|
||||
|
@ -773,17 +771,16 @@ fun UsageConditionsView(
|
|||
}
|
||||
|
||||
ColumnWithScrollBar(modifier = Modifier.fillMaxSize().padding(horizontal = DEFAULT_PADDING)) {
|
||||
val title = if (updated) MR.strings.operator_updated_conditions else MR.strings.operator_conditions_of_use
|
||||
AppBarTitle(stringResource(title), enableAlphaChanges = false, withPadding = false, bottomPadding = DEFAULT_PADDING)
|
||||
when (val conditionsAction = chatModel.conditions.value.conditionsAction) {
|
||||
is UsageConditionsAction.Review -> {
|
||||
AppBarTitle(stringResource(MR.strings.operator_updated_conditions), enableAlphaChanges = false, withPadding = false, bottomPadding = DEFAULT_PADDING)
|
||||
if (conditionsAction.operators.isNotEmpty()) {
|
||||
ReadableText(MR.strings.operators_conditions_will_be_accepted_for, args = conditionsAction.operators.joinToString(", ") { it.legalName_ })
|
||||
}
|
||||
Column(modifier = Modifier.weight(1f).padding(bottom = DEFAULT_PADDING, top = DEFAULT_PADDING_HALF)) {
|
||||
ConditionsTextView(rhId)
|
||||
}
|
||||
AcceptConditionsButton(conditionsAction.operators.map { it.operatorId }, close, if (conditionsAction.deadline != null || updated) DEFAULT_PADDING_HALF else DEFAULT_PADDING * 2)
|
||||
AcceptConditionsButton(conditionsAction.operators.map { it.operatorId }, close, DEFAULT_PADDING_HALF)
|
||||
if (conditionsAction.deadline != null) {
|
||||
SectionTextFooter(
|
||||
text = AnnotatedString(String.format(generalGetString(MR.strings.operator_conditions_accepted_for_enabled_operators_on), localDate(conditionsAction.deadline))),
|
||||
|
@ -791,13 +788,12 @@ fun UsageConditionsView(
|
|||
)
|
||||
Spacer(Modifier.fillMaxWidth().height(DEFAULT_PADDING))
|
||||
}
|
||||
if (updated) {
|
||||
ConditionsDiffButton()
|
||||
Spacer(Modifier.fillMaxWidth().height(DEFAULT_PADDING))
|
||||
}
|
||||
ConditionsDiffButton()
|
||||
Spacer(Modifier.fillMaxWidth().height(DEFAULT_PADDING))
|
||||
}
|
||||
|
||||
is UsageConditionsAction.Accepted -> {
|
||||
AppBarTitle(stringResource(MR.strings.operator_conditions_of_use), enableAlphaChanges = false, withPadding = false, bottomPadding = DEFAULT_PADDING)
|
||||
if (conditionsAction.operators.isNotEmpty()) {
|
||||
ReadableText(MR.strings.operators_conditions_accepted_for, args = conditionsAction.operators.joinToString(", ") { it.legalName_ })
|
||||
}
|
||||
|
@ -807,6 +803,7 @@ fun UsageConditionsView(
|
|||
}
|
||||
|
||||
else -> {
|
||||
AppBarTitle(stringResource(MR.strings.operator_conditions_of_use), enableAlphaChanges = false, withPadding = false, bottomPadding = DEFAULT_PADDING)
|
||||
Column(modifier = Modifier.weight(1f).padding(bottom = DEFAULT_PADDING, top = DEFAULT_PADDING_HALF)) {
|
||||
ConditionsTextView(rhId)
|
||||
}
|
||||
|
@ -815,6 +812,18 @@ fun UsageConditionsView(
|
|||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SimpleConditionsView(
|
||||
rhId: Long?
|
||||
) {
|
||||
ColumnWithScrollBar(modifier = Modifier.fillMaxSize().padding(horizontal = DEFAULT_PADDING)) {
|
||||
AppBarTitle(stringResource(MR.strings.operator_conditions_of_use), enableAlphaChanges = false, withPadding = false, bottomPadding = DEFAULT_PADDING)
|
||||
Column(modifier = Modifier.weight(1f).padding(bottom = DEFAULT_PADDING, top = DEFAULT_PADDING_HALF)) {
|
||||
ConditionsTextView(rhId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ServersErrorFooter(errStr: String) {
|
||||
Row(
|
||||
|
|
Loading…
Add table
Reference in a new issue