Skip to content

Commit

Permalink
#263: Fixed an iOS TaskDetailsView Style
Browse files Browse the repository at this point in the history
  • Loading branch information
janoliver20 committed Jul 22, 2024
1 parent 32fba28 commit 6c1dca4
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 52 deletions.
64 changes: 32 additions & 32 deletions iosApp/iosApp/Views/ObservationErrorListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,55 @@ import shared
import SwiftUI

struct ObservationErrorListView: View {
let taskObservationErrors: [String]
let taskObservationErrors: [String]
let taskObservationErrorActions: [String]

@State private var scrollViewContentSize: CGSize = .zero
private let errorStrings = "Errors"
private let navigationStrings = "Navigation"

var body: some View {
if !taskObservationErrors.isEmpty {
ScrollView {
VStack {
ForEach(taskObservationErrors, id: \.self) { error in
HStack {
Image(systemName: "exclamationmark.triangle")
.font(.more.headline)
.foregroundColor(.more.important)
.padding(.trailing, 4)
BasicText(text: "\(error.localize(withComment: "Error message", useTable: errorStrings))!")
if !taskObservationErrors.isEmpty || !taskObservationErrorActions.isEmpty {
VStack {
if !taskObservationErrors.isEmpty {
ScrollView {
VStack {
ForEach(taskObservationErrors, id: \.self) { error in
HStack {
Image(systemName: "exclamationmark.triangle")
.font(.more.headline)
.foregroundColor(.more.important)
.padding(.trailing, 4)
BasicText(text: "\(error.localize(withComment: "Error message", useTable: errorStrings))!")
}
.padding(.bottom)
}
}
.padding(.bottom)
}
.frame(maxHeight: 100)
}

}
if taskObservationErrorActions.isEmpty {
Divider()
}
}

if !taskObservationErrorActions.isEmpty {
if taskObservationErrorActions
.contains(Observation_.companion.ERROR_DEVICE_NOT_CONNECTED) {
MoreActionButton(disabled: .constant(false)) {
ViewManager.shared.showBLEView(state: true)
} label: {
HStack {
Image(systemName: "applewatch")
.foregroundColor(.more.white)
.padding(.trailing, 4)
Text(String.localize(forKey: "Devices", withComment: "Lists all connected or needed devices.", inTable: navigationStrings))
if !taskObservationErrorActions.isEmpty {
if taskObservationErrorActions
.contains(Observation_.companion.ERROR_DEVICE_NOT_CONNECTED) {
MoreActionButton(disabled: .constant(false)) {
ViewManager.shared.showBLEView(state: true)
} label: {
HStack {
Image(systemName: "applewatch")
.foregroundColor(.more.white)
.padding(.trailing, 4)
Text(String.localize(forKey: "Devices", withComment: "Lists all connected or needed devices.", inTable: navigationStrings))
}
}
}
}
}

Divider()
}
}
}

#Preview {
ObservationErrorListView(taskObservationErrors: [], taskObservationErrorActions: [Observation_.companion.ERROR_DEVICE_NOT_CONNECTED])
ObservationErrorListView(taskObservationErrors: ["Error"], taskObservationErrorActions: [Observation_.companion.ERROR_DEVICE_NOT_CONNECTED])

}
45 changes: 25 additions & 20 deletions iosApp/iosApp/Views/TaskDetails/TaskDetailsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct TaskDetailsView: View {

var body: some View {
MoreMainBackgroundView(contentPadding: 0) {
VStack(spacing: 20) {
VStack {
VStack {
HStack {
Title2(titleText: viewModel.taskDetailsModel?.observationTitle ?? "")
Expand Down Expand Up @@ -61,30 +61,35 @@ struct TaskDetailsView: View {
DatapointsCollection(datapoints: $viewModel.dataCount, running: detailsModel.state == .running)
}
Spacer()

ObservationErrorListView(taskObservationErrors: viewModel.taskObservationErrors, taskObservationErrorActions: viewModel.taskObservationErrorAction)
.background(
GeometryReader { geo -> Color in
DispatchQueue.main.async {
scrollViewContentSize = geo.size

VStack {
ObservationErrorListView(taskObservationErrors: viewModel.taskObservationErrors, taskObservationErrorActions: viewModel.taskObservationErrorAction)
.background(
GeometryReader { geo -> Color in
DispatchQueue.main.async {
scrollViewContentSize = geo.size
}
return Color.clear
}
return Color.clear
)
.frame(maxWidth: .infinity, maxHeight: 100)

if !detailsModel.hidden {
if let scheduleId = navigationModalState.navigationState(for: .taskDetails)?.scheduleId {
Divider()
ObservationButton(
observationActionDelegate: viewModel,
scheduleId: scheduleId,
observationType: detailsModel.observationType,
state: detailsModel.state,
disabled: !detailsModel.state.active() || !viewModel.taskObservationErrors.isEmpty)
.padding(.bottom)
}
)
.frame(maxWidth: .infinity, maxHeight: 150)

if !detailsModel.hidden {
if let scheduleId = navigationModalState.navigationState(for: .taskDetails)?.scheduleId {
ObservationButton(
observationActionDelegate: viewModel,
scheduleId: scheduleId,
observationType: detailsModel.observationType,
state: detailsModel.state,
disabled: !detailsModel.state.active() || !viewModel.taskObservationErrors.isEmpty)
}
}

}
Spacer()

}
.customNavigationTitle(with: NavigationScreen.taskDetails.localize(useTable: navigationStrings, withComment: "Task Detail"))
.onAppear {
Expand Down

0 comments on commit 6c1dca4

Please sign in to comment.