Просмотр исходного кода

UI fixes
* display profiles permanently, alignment of home view elements
* spacing fixes

polscm32 2 лет назад
Родитель
Сommit
4587e610d6

+ 5 - 5
FreeAPS/Sources/Modules/Bolus/View/AlternativeBolusCalcRootView.swift

@@ -401,7 +401,7 @@ extension Bolus {
                             .font(.footnote)
                             .buttonStyle(PlainButtonStyle())
                             .frame(maxWidth: .infinity, alignment: .leading)
-                        
+
                         if state.fattyMeals {
                             Spacer()
                             Toggle(isOn: $state.useFattyMealCorrectionFactor) {
@@ -481,8 +481,8 @@ extension Bolus {
                             keepForNextWiew = true
                             state.add()
                             state.hideModal()
-                            ///check if user pressed the calc button or just wanted to enter carbs
-                            ///otherwise carb entry is doubled
+                            /// check if user pressed the calc button or just wanted to enter carbs
+                            /// otherwise carb entry is doubled
                             if !calcButtonPressed {
                                 state.addCarbs(override, fetch: editMode)
                             }
@@ -499,8 +499,8 @@ extension Bolus {
                         Button {
                             keepForNextWiew = true
                             state.hideModal()
-                            ///check if user pressed the calc button or just wanted to enter carbs
-                            ///otherwise carb entry is doubled
+                            /// check if user pressed the calc button or just wanted to enter carbs
+                            /// otherwise carb entry is doubled
                             if !calcButtonPressed {
                                 state.addCarbs(override, fetch: editMode)
                             }

+ 11 - 11
FreeAPS/Sources/Modules/Home/View/Chart/MainChartView.swift

@@ -121,7 +121,7 @@ struct MainChartView: View {
         VStack {
             ScrollViewReader { scroller in
                 ScrollView(.horizontal, showsIndicators: false) {
-                    VStack(spacing: -0.00002) {
+                    VStack(spacing: 2) {
                         BasalChart()
 
                         MainChart()
@@ -161,9 +161,9 @@ extension MainChartView {
                 /// high and low treshold lines
                 if thresholdLines {
                     RuleMark(y: .value("High", highGlucose)).foregroundStyle(Color.loopYellow)
-                        .lineStyle(.init(lineWidth: 2, dash: [2]))
+                        .lineStyle(.init(lineWidth: 1))
                     RuleMark(y: .value("Low", lowGlucose)).foregroundStyle(Color.loopRed)
-                        .lineStyle(.init(lineWidth: 2, dash: [2]))
+                        .lineStyle(.init(lineWidth: 1))
                 }
                 RuleMark(
                     x: .value(
@@ -171,7 +171,7 @@ extension MainChartView {
                         Date(timeIntervalSince1970: TimeInterval(NSDate().timeIntervalSince1970)),
                         unit: .second
                     )
-                ).lineStyle(.init(lineWidth: 2, dash: [2])).foregroundStyle(Color.insulin)
+                ).lineStyle(.init(lineWidth: 2, dash: [3])).foregroundStyle(Color.insulin)
                 RuleMark(
                     x: .value(
                         "",
@@ -352,7 +352,7 @@ extension MainChartView {
                     calculatePredictions()
                 }
                 .frame(
-                    minHeight: UIScreen.main.bounds.height / 3
+                    minHeight: UIScreen.main.bounds.height / 3.1
                 )
                 .frame(width: fullWidth(viewWidth: screenSize.width))
                 .chartYScale(domain: minValue ... maxValue)
@@ -389,7 +389,7 @@ extension MainChartView {
                         Date(timeIntervalSince1970: TimeInterval(NSDate().timeIntervalSince1970)),
                         unit: .second
                     )
-                ).lineStyle(.init(lineWidth: 2, dash: [2])).foregroundStyle(Color.insulin)
+                ).lineStyle(.init(lineWidth: 2, dash: [3])).foregroundStyle(Color.insulin)
                 RuleMark(
                     x: .value(
                         "",
@@ -423,14 +423,14 @@ extension MainChartView {
                             xEnd: .value("end", nextTempStart),
                             yStart: .value("rate-start", 0),
                             yEnd: .value("rate-end", temp.rate ?? 0)
-                        ).foregroundStyle(Color.insulin.opacity(0.3))
+                        ).foregroundStyle(Color.insulin.opacity(0.5))
                     } else {
                         RectangleMark(
                             xStart: .value("start", temp.timestamp),
                             xEnd: .value("end", maxEndTime),
                             yStart: .value("rate-start", 0),
                             yEnd: .value("rate-end", temp.rate ?? 0)
-                        ).foregroundStyle(Color.insulin.opacity(0.3))
+                        ).foregroundStyle(Color.insulin.opacity(0.5))
                     }
                 }
                 /// dashed profile line
@@ -439,12 +439,12 @@ extension MainChartView {
                         x: .value("Start Date", profile.startDate),
                         y: .value("Amount", profile.amount),
                         series: .value("profile", "profile")
-                    ).lineStyle(.init(lineWidth: 2, dash: [2, 3])).foregroundStyle(Color.insulin)
+                    ).lineStyle(.init(lineWidth: 2, dash: [2, 4])).foregroundStyle(Color.insulin)
                     LineMark(
                         x: .value("End Date", profile.endDate ?? endMarker),
                         y: .value("Amount", profile.amount),
                         series: .value("profile", "profile")
-                    ).lineStyle(.init(lineWidth: 2.5, dash: [2, 3])).foregroundStyle(Color.insulin)
+                    ).lineStyle(.init(lineWidth: 2.5, dash: [2, 4])).foregroundStyle(Color.insulin)
                 }
             }.onChange(of: tempBasals) { _ in
                 calculateBasals()
@@ -465,7 +465,7 @@ extension MainChartView {
                 calculateTempBasals()
             }
             .frame(
-                minHeight: UIScreen.main.bounds.height / 10
+                minHeight: UIScreen.main.bounds.height / 9.9
             )
             .frame(width: fullWidth(viewWidth: screenSize.width))
             .rotationEffect(.degrees(180))

+ 54 - 156
FreeAPS/Sources/Modules/Home/View/HomeRootView.swift

@@ -390,112 +390,6 @@ extension Home {
             }
         }
 
-//        @ViewBuilder private func bottomPanel(_: GeometryProxy) -> some View {
-//            let colorIcon: Color = (colorScheme == .dark ? Color.white : Color.black).opacity(0.9)
-//
-//            ZStack {
-//                Rectangle()
-//                    .fill(Color("Chart"))
-//                    .frame(height: UIScreen.main.bounds.height / 13)
-//                    .cornerRadius(15)
-//                    .shadow(
-//                        color: colorScheme == .dark ? Color(red: 0.02745098039, green: 0.1098039216, blue: 0.1411764706) : Color
-//                            .black.opacity(0.33),
-//                        radius: 3
-//                    )
-//                    .padding([.leading, .trailing], 10)
-//
-//                HStack {
-//                    Button {
-//                        state.showModal(for: .dataTable)
-//                    }
-//                    label: {
-//                        if #available(iOS 17.0, *) {
-//                            Image(systemName: "book.pages")
-//                                .font(.system(size: 24))
-//                                .foregroundColor(colorIcon)
-//                                .padding(8)
-//                        } else {
-//                            Image(systemName: "book")
-//                                .font(.system(size: 24))
-//                                .foregroundColor(colorIcon)
-//                                .padding(8)
-//                        }
-//                    }
-//                    .foregroundColor(colorIcon)
-//                    .buttonStyle(.borderless)
-//                    Spacer()
-//                    Button { state.showModal(for: .addCarbs(editMode: false, override: false)) }
-//                    label: {
-//                        ZStack(alignment: Alignment(horizontal: .trailing, vertical: .bottom)) {
-//                            Image(systemName: "fork.knife")
-//                                .font(.system(size: 24))
-//                                .foregroundColor(colorIcon)
-//                                .padding(8)
-//                            if let carbsReq = state.carbsRequired {
-//                                Text(numberFormatter.string(from: carbsReq as NSNumber)!)
-//                                    .font(.caption)
-//                                    .foregroundColor(.white)
-//                                    .padding(4)
-//                                    .background(Capsule().fill(Color.red))
-//                            }
-//                        }
-//                    }.buttonStyle(.borderless)
-//                    Spacer()
-//                    Button {
-//                        state.showModal(for: .bolus(
-//                            waitForSuggestion: true,
-//                            fetch: false
-//                        ))
-//                    }
-//                    label: {
-//                        Image(systemName: "syringe.fill")
-//                            .font(.system(size: 24))
-//                            .foregroundColor(colorIcon)
-//                            .padding(8)
-//                    }
-//                    .foregroundColor(colorIcon)
-//                    .buttonStyle(.borderless)
-//                    Spacer()
-//                    if state.allowManualTemp {
-//                        Button { state.showModal(for: .manualTempBasal) }
-//                        label: {
-//                            Image("bolus1")
-//                                .renderingMode(.template)
-//                                .resizable()
-//                                .frame(width: 24, height: 24)
-//                                .padding(8)
-//                        }
-//                        .foregroundColor(colorIcon)
-//                        .buttonStyle(.borderless)
-//                        Spacer()
-//                    }
-//                    let isOverrideActive = fetchedPercent.first?.enabled ?? false
-//                    Button {
-//                        state.showModal(for: .overrideProfilesConfig)
-//                    } label: {
-//                        Image(systemName: (state.isTempTargetActive || isOverrideActive) ? "person.fill" : "person")
-//                            .font(.system(size: 26))
-//                            .padding(8)
-//                    }
-//                    .foregroundColor((state.isTempTargetActive || isOverrideActive) ? Color.purple : colorIcon)
-//                    .buttonStyle(.borderless)
-//                    Spacer()
-//                    Button {
-//                        state.showModal(for: .settings)
-//                    } label: {
-//                        Image(systemName: "gear")
-//                            .font(.system(size: 26))
-//                            .padding(8)
-//                    }
-//                    .foregroundColor(colorIcon)
-//                    .buttonStyle(.borderless)
-//                }
-//                .padding(.horizontal, 24)
-//                .padding(.bottom, 16)
-//            }
-//        }
-
         @ViewBuilder func bolusProgressBar(_ progress: Decimal) -> some View {
             GeometryReader { geo in
                 Rectangle()
@@ -564,7 +458,7 @@ extension Home {
                     Color.black.opacity(0.33),
                 radius: 3
             )
-            .frame(height: 62, alignment: .center)
+            .frame(height: UIScreen.main.bounds.height / 25, alignment: .center)
             .padding(.horizontal, 10)
             .offset(y: -90)
         }
@@ -679,45 +573,55 @@ extension Home {
                 "Chart"
             ) : .white
 
-            if let overrideString = overrideString {
-                ZStack {
-                    /// rectangle as background
-                    RoundedRectangle(cornerRadius: 15)
-                        .fill(colourChart)
-                        .clipShape(RoundedRectangle(cornerRadius: 15))
-                        .frame(height: UIScreen.main.bounds.height / 20)
-                        .shadow(
-                            color: colorScheme == .dark ? Color(red: 0.02745098039, green: 0.1098039216, blue: 0.1411764706) :
-                                Color.black.opacity(0.33),
-                            radius: 3
-                        )
-                    HStack {
-                        /// actual profile view
-                        Image(systemName: "person.fill")
-                            .font(.system(size: 20))
-                            .foregroundStyle(Color.purple)
-                        Spacer()
+            ZStack {
+                /// rectangle as background
+                RoundedRectangle(cornerRadius: 15)
+                    .fill(Color.insulin.opacity(0.1))
+                    .clipShape(RoundedRectangle(cornerRadius: 15))
+                    .frame(height: UIScreen.main.bounds.height / 25)
+                    .shadow(
+                        color: colorScheme == .dark ? Color(red: 0.02745098039, green: 0.1098039216, blue: 0.1411764706) :
+                            Color.black.opacity(0.33),
+                        radius: 3
+                    )
+                HStack {
+                    /// actual profile view
+                    Image(systemName: "person")
+                        .font(.system(size: 20))
+                    Spacer()
+
+                    if let overrideString = overrideString {
                         Text(overrideString)
                             .font(.system(size: 18))
                         Spacer()
                         Image(systemName: "xmark.app")
                             .font(.system(size: 20))
-                    }.padding(.horizontal, 10)
-                        .alert(
-                            "Return to Normal?", isPresented: $showCancelAlert,
-                            actions: {
-                                Button("No", role: .cancel) {}
-                                Button("Yes", role: .destructive) {
-                                    state.cancelProfile()
-                                }
-                            }, message: { Text("This will change settings back to your normal profile.") }
-                        )
-                        .padding(.trailing, 8)
-                        .onTapGesture {
-                            showCancelAlert = true
+                    } else {
+                        if tempTargetString == nil {
+                            Text("100 %")
+                                .font(.system(size: 18))
+                            Spacer()
+                            /// to ensure the same position....
+                            Image(systemName: "xmark.app")
+                                .font(.system(size: 20))
+                                .foregroundStyle(Color.clear)
                         }
-                }.padding(.horizontal, 10).padding(.bottom, 10)
-            }
+                    }
+                }.padding(.horizontal, 10)
+                    .alert(
+                        "Return to Normal?", isPresented: $showCancelAlert,
+                        actions: {
+                            Button("No", role: .cancel) {}
+                            Button("Yes", role: .destructive) {
+                                state.cancelProfile()
+                            }
+                        }, message: { Text("This will change settings back to your normal profile.") }
+                    )
+                    .padding(.trailing, 8)
+                    .onTapGesture {
+                        showCancelAlert = true
+                    }
+            }.padding(.horizontal, 10).padding(.bottom, 10)
 
             /// just show temp target if no profile is already active
             if overrideString == nil, let tempTargetString = tempTargetString {
@@ -853,7 +757,7 @@ extension Home {
 
         @ViewBuilder func mainView() -> some View {
             GeometryReader { geo in
-                ZStack(alignment: .trailing) {
+                ZStack(alignment: .bottom) {
                     VStack(spacing: 0) {
                         Spacer()
 
@@ -884,15 +788,9 @@ extension Home {
                                 }.padding(.trailing, 20).padding(.bottom, 110)
                             }
 
-                        }.padding(.top, 40)
-
-                        Spacer()
-
-                        mealPanel(geo)
+                        }.padding(.top, 10)
 
-                        Spacer()
-
-                        profileView(geo)
+                        mealPanel(geo).padding(.top, 30).padding(.bottom, 20)
 
                         RoundedRectangle(cornerRadius: 15)
                             .fill(Color("Chart"))
@@ -904,17 +802,17 @@ extension Home {
                                 radius: 3
                             )
                             .padding(.horizontal, 10)
-                            .frame(maxHeight: UIScreen.main.bounds.height / 2.1)
-
-                        Spacer()
+                            .frame(maxHeight: UIScreen.main.bounds.height / 2.2)
 
-                        timeInterval.padding(.bottom, 70)
+                        timeInterval.padding(.top, 20).padding(.bottom, 90)
 
                         Spacer()
+                    }
 
-                        if let progress = state.bolusProgress {
-                            bolusProgressView(geo, progress)
-                        }
+                    if let progress = state.bolusProgress {
+                        bolusProgressView(geo, progress).padding(.bottom, 20)
+                    } else {
+                        profileView(geo).padding(.bottom, 80)
                     }
                 }
                 .background(color)