Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jasudev committed Mar 1, 2022
1 parent b8f02ff commit adb25ed
Show file tree
Hide file tree
Showing 24 changed files with 1,762 additions and 1 deletion.
496 changes: 496 additions & 0 deletions AxisTooltipExample/AxisTooltipExample.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 6 additions & 0 deletions AxisTooltipExample/Shared/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
18 changes: 18 additions & 0 deletions AxisTooltipExample/Shared/AxisTooltipExampleApp.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// AxisTooltipExampleApp.swift
// AxisTooltipExample
//
// Created by jasu on 2022/02/27.
// Copyright (c) 2022 jasu All rights reserved.
//

import SwiftUI

@main
struct AxisTooltipExampleApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
163 changes: 163 additions & 0 deletions AxisTooltipExample/Shared/ContentView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
//
// ContentView.swift
// AxisTooltipExample
//
// Created by jasu on 2022/02/27.
// Copyright (c) 2022 jasu All rights reserved.
//

import SwiftUI
import AxisTooltip

struct ContentView: View {

@State private var isPresented: Bool = true
@State private var constant: ATConstant = .init(border: ATBorderConstant(color: .pink))

let alignments: [Alignment] = [.center, .leading, .trailing, .top, .bottom, .topLeading, .topTrailing, .bottomLeading, .bottomTrailing]
@State private var alignmentIndex: Int = 0

var body: some View {

NavigationView {
NavigationLink("Show") {
VStack {
ZStack {
Text("AxisTooltip")
.bold()
.padding()
.background(Color.pink)
.cornerRadius(10)
.onTapGesture {
isPresented.toggle()
}
.axisToolTip(isPresented: $isPresented, alignment: alignments[alignmentIndex], constant: constant, foreground: {
Label("Contrary to popular belief, Lorem Ipsum is not simply random text.", systemImage: "heart")
.padding()
.frame(width: 200)
})
}
.background(Color.blue.opacity(0.2))
Spacer()
VStack {
VStack(alignment: .leading, spacing: 5) {
Text("● Border").foregroundColor(Color.accentColor).opacity(0.5)
HStack {
HStack {
Text(" color :").opacity(0.5)
ColorPicker("", selection: $constant.border.color).labelsHidden()
}
Divider().frame(maxHeight: 40)
HStack {
Text(" style :").opacity(0.5)
Button {
if constant.border.style == nil {
constant.border.style = StrokeStyle(lineWidth: 2, dash: [5])
}else {
constant.border.style = nil
}
} label: {
Text(constant.border.style == nil ? "Off" : "On")
.padding(7)
.background(constant.border.style == nil ? Color.gray.opacity(0.2) : Color.accentColor)
.cornerRadius(8)
}
.buttonStyle((PlainButtonStyle()))
}
}
HStack {
Text(" radius :").opacity(0.5)
Slider(value: $constant.border.radius, in: 0...26)
Text("\(constant.border.radius, specifier: "%.2f")")
}
HStack {
Text(" lineWidth :").opacity(0.5)
Slider(value: $constant.border.lineWidth, in: 0...26)
Text("\(constant.border.lineWidth, specifier: "%.2f")")
}
.disabled(constant.border.style != nil)
.opacity(constant.border.style != nil ? 0.5 : 1)
}

VStack(alignment: .leading, spacing: 5) {
Text("● Arrow").foregroundColor(Color.accentColor).opacity(0.5)
HStack {
VStack {
HStack {
Text(" width : ").opacity(0.5)
Spacer()
Text("\(constant.arrow.width, specifier: "%.2f")")
}
Slider(value: $constant.arrow.width, in: 0...26)
}
Divider().frame(maxHeight: 40)
VStack {
HStack {
Text(" height : ").opacity(0.5)
Spacer()
Text("\(constant.arrow.height, specifier: "%.2f")")
}
Slider(value: $constant.arrow.height, in: 0...26)
}
}
}
VStack(alignment: .leading, spacing: 5) {
Text("● distance").foregroundColor(Color.accentColor).opacity(0.5)
HStack {
Slider(value: $constant.distance, in: 0...26)
Text("\(constant.distance, specifier: "%.2f")")
}
}
VStack(alignment: .leading, spacing: 5) {
Text("● AxisMode").foregroundColor(Color.accentColor).opacity(0.5)
HStack {
Picker("", selection: $constant.axisMode) {
Text("Top").tag(ATAxisMode.top)
Text("Bottom").tag(ATAxisMode.bottom)
Text("Leading").tag(ATAxisMode.leading)
Text("Trailing").tag(ATAxisMode.trailing)
}
.pickerStyle(SegmentedPickerStyle())
Toggle("", isOn: $isPresented).labelsHidden()
}
}
Picker("", selection: $alignmentIndex) {
ForEach(Array(alignments.enumerated()), id:\.offset) { index, align in
Image(systemName: getAlignmentIcon(alignments[index])).tag(index)
}
}
.pickerStyle(SegmentedPickerStyle())
}
.zIndex(-1)
}
.font(.callout)
.animation(.easeInOut, value: constant)
.animation(.easeInOut, value: alignmentIndex)
.padding()
.navigationBarTitleDisplayMode(.inline)
}
}
}

private func getAlignmentIcon(_ alignment: Alignment) -> String {
switch alignment {
case .center: return "rectangle.center.inset.filled"
case .leading: return "rectangle.leftthird.inset.filled"
case .trailing: return "rectangle.rightthird.inset.filled"
case .top: return "rectangle.topthird.inset.filled"
case .bottom: return "rectangle.bottomthird.inset.filled"
case .topLeading: return "rectangle.inset.topleft.filled"
case .topTrailing: return "rectangle.inset.topright.filled"
case .bottomLeading: return "rectangle.inset.bottomleft.filled"
case .bottomTrailing: return "rectangle.inset.bottomright.filled"
default:
return ""
}
}
}

struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView().preferredColorScheme(.dark)
}
}
10 changes: 10 additions & 0 deletions AxisTooltipExample/macOS/macOS.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>
Binary file added Markdown/Bottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Markdown/Leading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Markdown/Top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Markdown/Trailing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit adb25ed

Please sign in to comment.