๐Ÿ‘”WidthDimension

โฌ†๏ธ ้œ€่ฆ๏ผš LeftArrow

struct WidthDimension: View {
    // view properties
    var label: Color = .primary
    var arrow: Color = .secondary
    // view body
    var body: some View {
        // โญ๏ธ ไฝฟ็”จ GeometryReader ไพ†่ฎ€ๅ–ใ€Œๅฏฌๅบฆใ€
        GeometryReader { geo in 
            let width = geo.size.width
            HStack{
                // ๐Ÿ‘” LeftArrow
                LeftArrow(color: arrow)
                // dimension
                Text("\(width, specifier: "%.0f")")   // โญ๏ธ no decimal places
                    .font(.system(size: 14)).bold()
                    .foregroundColor(label)
                    .fixedSize()                      // โญ๏ธ no wrap
                // ๐Ÿ‘” LeftArrow
                LeftArrow(color: arrow)
                    .scaleEffect(-1, anchor: .center) // โญ๏ธ turn around
            }
        }.frame(height: 25)    // โญ๏ธโญ๏ธโญ๏ธ ้€™่ฃกๆŒ‡ๅฎš้ซ˜ๅบฆๅพˆ้‡่ฆโ—๏ธ 
    }                          // ไธ็„ถ GeometryReader ๆœƒไฝ”ๆปฟๆ•ดๅ€‹็ฉบ้–“๏ผŒ
}                              // ้€ ๆˆๅค–็•Œไฝฟ็”จ overlay ๆ™‚ๅฐ้ฝŠ็„กๆ•ˆโ—๏ธ

Last updated