Sfoglia il codice sorgente

Extend fix of #248 and force wrapping to 2 lines #252

Deniz Cengiz 1 anno fa
parent
commit
288a060878
1 ha cambiato i file con 12 aggiunte e 2 eliminazioni
  1. 12 2
      FreeAPS/Sources/Modules/Home/View/Header/PumpView.swift

+ 12 - 2
FreeAPS/Sources/Modules/Home/View/Header/PumpView.swift

@@ -102,10 +102,20 @@ struct PumpView: View {
                             .font(.callout)
                             .foregroundStyle(timerColor)
 
-                        Text(remainingTimeString(time: date.timeIntervalSince(timerDate)))
-                            .font(!(date.timeIntervalSince(timerDate) > 0) ? .subheadline : .callout)
+                        let remainingTimeString = remainingTimeString(time: date.timeIntervalSince(timerDate))
+
+                        Text(remainingTimeString)
+                            .font(date.timeIntervalSince(timerDate) > 0 ? .callout : .subheadline)
                             .fontWeight(.bold)
                             .fontDesign(.rounded)
+                            .lineLimit(2)
+                            .multilineTextAlignment(.leading)
+                            .frame(
+                                // If the string is > 6 chars, i.e., exceeds "xd yh", limit width to 80 pts
+                                // This forces the "Replace pod" string to wrap to 2 lines.
+                                maxWidth: remainingTimeString.count > 6 ? 80 : .infinity,
+                                alignment: .leading
+                            )
                     }
                     // aligns the stopwatch icon exactly with the first pixel of the reservoir icon
                     .padding(.leading, date.timeIntervalSince(timerDate) > 0 ? 12 : 0)