summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/ChipView/ChipView.swift
blob: f79743faf7ad8973d15247c5f9b3ab02d2202968 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
//  FeatureChipView.swift
//  MullvadVPN
//
//  Created by Mojgan on 2024-12-05.
//  Copyright © 2025 Mullvad VPN AB. All rights reserved.
//

import SwiftUI

struct ChipView: View {
    let item: ChipModel
    let onPress: (() -> Void)?
    private let borderWidth: CGFloat = 1

    var body: some View {
        Button {
            onPress?()
        } label: {
            Text(item.name)
                .font(.subheadline)
                .lineLimit(1)
                .foregroundStyle(UIColor.primaryTextColor.color)
                .padding(.horizontal, UIMetrics.FeatureIndicators.chipViewHorisontalPadding)
                .padding(.vertical, 4)
                .background(
                    RoundedRectangle(cornerRadius: 8)
                        .stroke(
                            UIColor.primaryColor.color,
                            lineWidth: borderWidth
                        )
                        .background(
                            RoundedRectangle(cornerRadius: 8)
                                .fill(UIColor.secondaryColor.color)
                        )
                        .padding(borderWidth)
                )
        }
    }
}

#Preview {
    ZStack {
        ChipView(item: ChipModel(id: .daita, name: "Example")) {}
    }
    .frame(maxWidth: .infinity, maxHeight: .infinity)
    .background(UIColor.secondaryColor.color)
}