Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#263: Fixed an iOS TaskDetailsView Style #267

Merged
Merged
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
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