Skip to content

Commit

Permalink
Right align network speed and uppercase unit
Browse files Browse the repository at this point in the history
  • Loading branch information
gao-sun committed Oct 26, 2020
1 parent 63a57ae commit f81656d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
8 changes: 4 additions & 4 deletions eul/Utilities/ByteUnit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ public struct ByteUnit {
public var readable: String {
switch bytes {
case 0..<(1024 * 1024):
return "\(String(format: "%.\(kilobytes >= 100 ? 0 : 1)f", kilobytes)) kb"
return "\(String(format: "%.\(kilobytes >= 100 ? 0 : 1)f", kilobytes)) KB"
case 1024..<(1024 * 1024 * 1024):
return "\(String(format: "%.\(megabytes >= 100 ? 0 : 1)f", megabytes)) mb"
return "\(String(format: "%.\(megabytes >= 100 ? 0 : 1)f", megabytes)) MB"
case (1024 * 1024 * 1024)...UInt64.max:
return "\(String(format: "%.\(gigabytes >= 100 ? 0 : 1)f", gigabytes)) gb"
return "\(String(format: "%.\(gigabytes >= 100 ? 0 : 1)f", gigabytes)) GB"
default:
return "\(bytes) bytes"
return "\(bytes) Bytes"
}
}
}
3 changes: 2 additions & 1 deletion eul/Views/Components/StatusBarTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import SwiftUI
struct StatusBarTextView: View {
@ObservedObject var preferenceStore = PreferenceStore.shared
var texts: [String] = []
var alignment: HorizontalAlignment = .leading

var fontDesign: Font.Design {
preferenceStore.fontDesign.value
}

func getCompactRow(_ index: Int) -> some View {
VStack(alignment: .leading, spacing: 0) {
VStack(alignment: alignment, spacing: 0) {
Text(self.texts[index * 2])
.compact(design: fontDesign)
Text(self.texts[index * 2 + 1])
Expand Down
6 changes: 3 additions & 3 deletions eul/Views/StatusBar/NetworkView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct NetworkView: View {

var textWidth: CGFloat? {
if preferenceStore.textDisplay == .compact {
return 45
return 50
}
return preferenceStore.fontDesign == .default ? 120 : 145
}
Expand All @@ -30,8 +30,8 @@ struct NetworkView: View {
.resizable()
.frame(width: 13, height: 13)
}
StatusBarTextView(texts: texts)
.frame(width: textWidth)
StatusBarTextView(texts: texts, alignment: .trailing)
.frame(width: textWidth, alignment: .trailing)
}
}
}

0 comments on commit f81656d

Please sign in to comment.