Skip to content

Commit adb25ed

Browse files
committed
first commit
1 parent b8f02ff commit adb25ed

File tree

24 files changed

+1762
-1
lines changed

24 files changed

+1762
-1
lines changed

AxisTooltipExample/AxisTooltipExample.xcodeproj/project.pbxproj

Lines changed: 496 additions & 0 deletions
Large diffs are not rendered by default.

AxisTooltipExample/AxisTooltipExample.xcodeproj/project.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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"scale" : "2x",
6+
"size" : "20x20"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"scale" : "3x",
11+
"size" : "20x20"
12+
},
13+
{
14+
"idiom" : "iphone",
15+
"scale" : "2x",
16+
"size" : "29x29"
17+
},
18+
{
19+
"idiom" : "iphone",
20+
"scale" : "3x",
21+
"size" : "29x29"
22+
},
23+
{
24+
"idiom" : "iphone",
25+
"scale" : "2x",
26+
"size" : "40x40"
27+
},
28+
{
29+
"idiom" : "iphone",
30+
"scale" : "3x",
31+
"size" : "40x40"
32+
},
33+
{
34+
"idiom" : "iphone",
35+
"scale" : "2x",
36+
"size" : "60x60"
37+
},
38+
{
39+
"idiom" : "iphone",
40+
"scale" : "3x",
41+
"size" : "60x60"
42+
},
43+
{
44+
"idiom" : "ipad",
45+
"scale" : "1x",
46+
"size" : "20x20"
47+
},
48+
{
49+
"idiom" : "ipad",
50+
"scale" : "2x",
51+
"size" : "20x20"
52+
},
53+
{
54+
"idiom" : "ipad",
55+
"scale" : "1x",
56+
"size" : "29x29"
57+
},
58+
{
59+
"idiom" : "ipad",
60+
"scale" : "2x",
61+
"size" : "29x29"
62+
},
63+
{
64+
"idiom" : "ipad",
65+
"scale" : "1x",
66+
"size" : "40x40"
67+
},
68+
{
69+
"idiom" : "ipad",
70+
"scale" : "2x",
71+
"size" : "40x40"
72+
},
73+
{
74+
"idiom" : "ipad",
75+
"scale" : "1x",
76+
"size" : "76x76"
77+
},
78+
{
79+
"idiom" : "ipad",
80+
"scale" : "2x",
81+
"size" : "76x76"
82+
},
83+
{
84+
"idiom" : "ipad",
85+
"scale" : "2x",
86+
"size" : "83.5x83.5"
87+
},
88+
{
89+
"idiom" : "ios-marketing",
90+
"scale" : "1x",
91+
"size" : "1024x1024"
92+
},
93+
{
94+
"idiom" : "mac",
95+
"scale" : "1x",
96+
"size" : "16x16"
97+
},
98+
{
99+
"idiom" : "mac",
100+
"scale" : "2x",
101+
"size" : "16x16"
102+
},
103+
{
104+
"idiom" : "mac",
105+
"scale" : "1x",
106+
"size" : "32x32"
107+
},
108+
{
109+
"idiom" : "mac",
110+
"scale" : "2x",
111+
"size" : "32x32"
112+
},
113+
{
114+
"idiom" : "mac",
115+
"scale" : "1x",
116+
"size" : "128x128"
117+
},
118+
{
119+
"idiom" : "mac",
120+
"scale" : "2x",
121+
"size" : "128x128"
122+
},
123+
{
124+
"idiom" : "mac",
125+
"scale" : "1x",
126+
"size" : "256x256"
127+
},
128+
{
129+
"idiom" : "mac",
130+
"scale" : "2x",
131+
"size" : "256x256"
132+
},
133+
{
134+
"idiom" : "mac",
135+
"scale" : "1x",
136+
"size" : "512x512"
137+
},
138+
{
139+
"idiom" : "mac",
140+
"scale" : "2x",
141+
"size" : "512x512"
142+
}
143+
],
144+
"info" : {
145+
"author" : "xcode",
146+
"version" : 1
147+
}
148+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// AxisTooltipExampleApp.swift
3+
// AxisTooltipExample
4+
//
5+
// Created by jasu on 2022/02/27.
6+
// Copyright (c) 2022 jasu All rights reserved.
7+
//
8+
9+
import SwiftUI
10+
11+
@main
12+
struct AxisTooltipExampleApp: App {
13+
var body: some Scene {
14+
WindowGroup {
15+
ContentView()
16+
}
17+
}
18+
}
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
//
2+
// ContentView.swift
3+
// AxisTooltipExample
4+
//
5+
// Created by jasu on 2022/02/27.
6+
// Copyright (c) 2022 jasu All rights reserved.
7+
//
8+
9+
import SwiftUI
10+
import AxisTooltip
11+
12+
struct ContentView: View {
13+
14+
@State private var isPresented: Bool = true
15+
@State private var constant: ATConstant = .init(border: ATBorderConstant(color: .pink))
16+
17+
let alignments: [Alignment] = [.center, .leading, .trailing, .top, .bottom, .topLeading, .topTrailing, .bottomLeading, .bottomTrailing]
18+
@State private var alignmentIndex: Int = 0
19+
20+
var body: some View {
21+
22+
NavigationView {
23+
NavigationLink("Show") {
24+
VStack {
25+
ZStack {
26+
Text("AxisTooltip")
27+
.bold()
28+
.padding()
29+
.background(Color.pink)
30+
.cornerRadius(10)
31+
.onTapGesture {
32+
isPresented.toggle()
33+
}
34+
.axisToolTip(isPresented: $isPresented, alignment: alignments[alignmentIndex], constant: constant, foreground: {
35+
Label("Contrary to popular belief, Lorem Ipsum is not simply random text.", systemImage: "heart")
36+
.padding()
37+
.frame(width: 200)
38+
})
39+
}
40+
.background(Color.blue.opacity(0.2))
41+
Spacer()
42+
VStack {
43+
VStack(alignment: .leading, spacing: 5) {
44+
Text("● Border").foregroundColor(Color.accentColor).opacity(0.5)
45+
HStack {
46+
HStack {
47+
Text(" color :").opacity(0.5)
48+
ColorPicker("", selection: $constant.border.color).labelsHidden()
49+
}
50+
Divider().frame(maxHeight: 40)
51+
HStack {
52+
Text(" style :").opacity(0.5)
53+
Button {
54+
if constant.border.style == nil {
55+
constant.border.style = StrokeStyle(lineWidth: 2, dash: [5])
56+
}else {
57+
constant.border.style = nil
58+
}
59+
} label: {
60+
Text(constant.border.style == nil ? "Off" : "On")
61+
.padding(7)
62+
.background(constant.border.style == nil ? Color.gray.opacity(0.2) : Color.accentColor)
63+
.cornerRadius(8)
64+
}
65+
.buttonStyle((PlainButtonStyle()))
66+
}
67+
}
68+
HStack {
69+
Text(" radius :").opacity(0.5)
70+
Slider(value: $constant.border.radius, in: 0...26)
71+
Text("\(constant.border.radius, specifier: "%.2f")")
72+
}
73+
HStack {
74+
Text(" lineWidth :").opacity(0.5)
75+
Slider(value: $constant.border.lineWidth, in: 0...26)
76+
Text("\(constant.border.lineWidth, specifier: "%.2f")")
77+
}
78+
.disabled(constant.border.style != nil)
79+
.opacity(constant.border.style != nil ? 0.5 : 1)
80+
}
81+
82+
VStack(alignment: .leading, spacing: 5) {
83+
Text("● Arrow").foregroundColor(Color.accentColor).opacity(0.5)
84+
HStack {
85+
VStack {
86+
HStack {
87+
Text(" width : ").opacity(0.5)
88+
Spacer()
89+
Text("\(constant.arrow.width, specifier: "%.2f")")
90+
}
91+
Slider(value: $constant.arrow.width, in: 0...26)
92+
}
93+
Divider().frame(maxHeight: 40)
94+
VStack {
95+
HStack {
96+
Text(" height : ").opacity(0.5)
97+
Spacer()
98+
Text("\(constant.arrow.height, specifier: "%.2f")")
99+
}
100+
Slider(value: $constant.arrow.height, in: 0...26)
101+
}
102+
}
103+
}
104+
VStack(alignment: .leading, spacing: 5) {
105+
Text("● distance").foregroundColor(Color.accentColor).opacity(0.5)
106+
HStack {
107+
Slider(value: $constant.distance, in: 0...26)
108+
Text("\(constant.distance, specifier: "%.2f")")
109+
}
110+
}
111+
VStack(alignment: .leading, spacing: 5) {
112+
Text("● AxisMode").foregroundColor(Color.accentColor).opacity(0.5)
113+
HStack {
114+
Picker("", selection: $constant.axisMode) {
115+
Text("Top").tag(ATAxisMode.top)
116+
Text("Bottom").tag(ATAxisMode.bottom)
117+
Text("Leading").tag(ATAxisMode.leading)
118+
Text("Trailing").tag(ATAxisMode.trailing)
119+
}
120+
.pickerStyle(SegmentedPickerStyle())
121+
Toggle("", isOn: $isPresented).labelsHidden()
122+
}
123+
}
124+
Picker("", selection: $alignmentIndex) {
125+
ForEach(Array(alignments.enumerated()), id:\.offset) { index, align in
126+
Image(systemName: getAlignmentIcon(alignments[index])).tag(index)
127+
}
128+
}
129+
.pickerStyle(SegmentedPickerStyle())
130+
}
131+
.zIndex(-1)
132+
}
133+
.font(.callout)
134+
.animation(.easeInOut, value: constant)
135+
.animation(.easeInOut, value: alignmentIndex)
136+
.padding()
137+
.navigationBarTitleDisplayMode(.inline)
138+
}
139+
}
140+
}
141+
142+
private func getAlignmentIcon(_ alignment: Alignment) -> String {
143+
switch alignment {
144+
case .center: return "rectangle.center.inset.filled"
145+
case .leading: return "rectangle.leftthird.inset.filled"
146+
case .trailing: return "rectangle.rightthird.inset.filled"
147+
case .top: return "rectangle.topthird.inset.filled"
148+
case .bottom: return "rectangle.bottomthird.inset.filled"
149+
case .topLeading: return "rectangle.inset.topleft.filled"
150+
case .topTrailing: return "rectangle.inset.topright.filled"
151+
case .bottomLeading: return "rectangle.inset.bottomleft.filled"
152+
case .bottomTrailing: return "rectangle.inset.bottomright.filled"
153+
default:
154+
return ""
155+
}
156+
}
157+
}
158+
159+
struct ContentView_Previews: PreviewProvider {
160+
static var previews: some View {
161+
ContentView().preferredColorScheme(.dark)
162+
}
163+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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>com.apple.security.app-sandbox</key>
6+
<true/>
7+
<key>com.apple.security.files.user-selected.read-only</key>
8+
<true/>
9+
</dict>
10+
</plist>

Markdown/Bottom.png

261 KB
Loading

0 commit comments

Comments
 (0)