Skip to content

Commit 306be15

Browse files
committed
Initial commit
0 parents  commit 306be15

File tree

7 files changed

+172
-0
lines changed

7 files changed

+172
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>SchemeUserState</key>
6+
<dict>
7+
<key>CustomLabels.xcscheme_^#shared#^_</key>
8+
<dict>
9+
<key>orderHint</key>
10+
<integer>0</integer>
11+
</dict>
12+
</dict>
13+
<key>SuppressBuildableAutocreation</key>
14+
<dict>
15+
<key>CustomLabels</key>
16+
<dict>
17+
<key>primary</key>
18+
<true/>
19+
</dict>
20+
<key>CustomLabelsTests</key>
21+
<dict>
22+
<key>primary</key>
23+
<true/>
24+
</dict>
25+
</dict>
26+
</dict>
27+
</plist>

Package.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// swift-tools-version: 6.1
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "CustomLabels",
8+
platforms: [
9+
.iOS(.v16)
10+
],
11+
products: [
12+
.library(
13+
name: "CustomLabels",
14+
targets: ["CustomLabels"]),
15+
],
16+
targets: [
17+
.target(
18+
name: "CustomLabels"),
19+
.testTarget(
20+
name: "CustomLabelsTests",
21+
dependencies: ["CustomLabels"]
22+
),
23+
]
24+
)
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// The Swift Programming Language
2+
// https://docs.swift.org/swift-book
3+
4+
import SwiftUI
5+
6+
@available(iOS 16.0, *)
7+
public struct CustomButtonLabel: View {
8+
var iconLeading: String?
9+
var iconTrailing: String?
10+
let message: String
11+
var color: Color = .blue
12+
var isSelected: Bool = true
13+
var fontSize: CGFloat = 16
14+
15+
public init(iconLeading: String? = nil,
16+
iconTrailing: String? = nil,
17+
message: String,
18+
color: Color = .blue,
19+
isSelected: Bool = true,
20+
fontSize: CGFloat = 16) {
21+
self.iconLeading = iconLeading
22+
self.iconTrailing = iconTrailing
23+
self.message = message
24+
self.color = color
25+
self.isSelected = isSelected
26+
self.fontSize = fontSize
27+
}
28+
29+
public var body: some View {
30+
HStack {
31+
if iconTrailing != nil {
32+
Spacer()
33+
}
34+
if let iconLeading = iconLeading {
35+
Image(systemName: iconLeading) }
36+
Text(LocalizedStringKey(message))
37+
if let iconTrailing = iconTrailing {
38+
Spacer()
39+
Image(systemName: iconTrailing)
40+
.padding(.trailing, 20)
41+
}
42+
}
43+
.font(.system(size: fontSize))
44+
.appButtonStyle(color: color, isSelected: isSelected)
45+
}
46+
}
47+
48+
@available(iOS 16.0, *)
49+
public struct CustomButtonIcon: View {
50+
let icon: String
51+
let color: Color
52+
53+
public init(icon: String, color: Color) {
54+
self.icon = icon
55+
self.color = color
56+
}
57+
58+
public var body: some View {
59+
Image(systemName: icon)
60+
.fontWeight(.bold)
61+
.padding(7)
62+
.background(color)
63+
.foregroundColor(.white)
64+
.cornerRadius(25)
65+
.shadow(color: .gray, radius: 4, x: 2, y: 2)
66+
}
67+
}
68+
69+
@available(iOS 16.0, *)
70+
public struct AppButtonStyle: ViewModifier {
71+
var color: Color
72+
var isSelected: Bool = true
73+
74+
public func body(content: Content) -> some View {
75+
content
76+
.fontWeight(.bold)
77+
.padding(.vertical)
78+
.frame(maxWidth: .infinity)
79+
.background(isSelected ? color : Color.clear)
80+
.foregroundColor(isSelected ? .white : color)
81+
.cornerRadius(8)
82+
.overlay(
83+
RoundedRectangle(cornerRadius: 8)
84+
.stroke(color, lineWidth: isSelected ? 0 : 2)
85+
)
86+
.shadow(
87+
color: isSelected ? .primary.opacity(0.3) : .clear,
88+
radius: 4,
89+
x: 0,
90+
y: isSelected ? 0 : 2
91+
)
92+
.scaleEffect(isSelected ? 1.0 : 0.95)
93+
}
94+
}
95+
96+
@available(iOS 16.0, *)
97+
extension View {
98+
func appButtonStyle(color: Color, isSelected: Bool = true) -> some View {
99+
self.modifier(AppButtonStyle(color: color, isSelected: isSelected))
100+
}
101+
}
102+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import XCTest
2+
@testable import CustomLabels
3+
4+
final class CustomLabelsTests: XCTestCase {
5+
func testExample() throws {
6+
// XCTest Documentation
7+
// https://developer.apple.com/documentation/xctest
8+
9+
// Defining Test Cases and Test Methods
10+
// https://developer.apple.com/documentation/xctest/defining_test_cases_and_test_methods
11+
}
12+
}

0 commit comments

Comments
 (0)