Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat SwiftUI Hint #269

Merged
merged 215 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 209 commits
Commits
Show all changes
215 commits
Select commit Hold shift + click to select a range
38280a7
Add Tooltip view
kevinneko Jan 30, 2024
6bff03f
Refactor Tooltip style
kevinneko Jan 30, 2024
7caa72c
Merge branch 'main' into feat-swiftui-tooltip
kevinneko Jan 31, 2024
c5e0daa
Can adjust tooltip position
kevinneko Jan 31, 2024
cbd58af
Add tooltip playground for testing
kevinneko Jan 31, 2024
7d13811
Refine layout tips logic
kevinneko Jan 31, 2024
874a5b9
Refine layout logic
kevinneko Jan 31, 2024
eecaff8
Update CharcoalTooltip.swift
kevinneko Jan 31, 2024
0ea9f6a
Refine tooltip spacing
kevinneko Feb 6, 2024
085626f
Add CharcoalIdentifiableOverlayView
kevinneko Feb 6, 2024
b12beac
Use Actor to prevent Data Race
kevinneko Feb 6, 2024
d2c39e5
Remove CharcoalIdentifiableOverlayView out
kevinneko Feb 6, 2024
83cb45f
Clean code
kevinneko Feb 6, 2024
1a5cd1b
Only update view when it is isPresenting
kevinneko Feb 6, 2024
747da2a
Clean access control
kevinneko Feb 6, 2024
61fd850
Add TooltipsView
kevinneko Feb 6, 2024
7883c8a
Fix tooltipY layout logic
kevinneko Feb 6, 2024
a0cbea0
Use main actor and remove CharcoalContainerManagerKey
kevinneko Feb 6, 2024
bbb6b90
Fix access control on CharcoalContainerManager
kevinneko Feb 6, 2024
f5b77b3
Make viewID as @State
kevinneko Feb 6, 2024
5020edf
Use EnviromentObject to create CharcoalContainerManager for each cont…
kevinneko Feb 8, 2024
793a635
Use ObservedObject on CharcoalContainerManager
kevinneko Feb 8, 2024
131c2dd
Add use charcoal button as demo trigger
kevinneko Feb 12, 2024
3b4e47b
Add arrow logic on tooltip
kevinneko Feb 12, 2024
d902eed
Refine arrow logic
kevinneko Feb 12, 2024
9ae7e05
Refine arrow layout logic
kevinneko Feb 12, 2024
968feb9
Use StateObject to prevent unexpected reinit
kevinneko Feb 12, 2024
1539dac
Refactor TooltipBubbleShape
kevinneko Feb 12, 2024
ca43fec
Fix edge layout logic
kevinneko Feb 12, 2024
506345d
Add comment
kevinneko Feb 12, 2024
08b32dd
Format code
kevinneko Feb 12, 2024
2de961e
Use new approach to remove adaptiveMaxWidth
kevinneko Feb 12, 2024
64586f5
Fix the tip bubble's position latency
kevinneko Feb 12, 2024
abdd345
Add dismiss when interaction
kevinneko Feb 20, 2024
e38ca0e
Reformat
kevinneko Feb 20, 2024
720bb56
Add initial Snackbar
kevinneko Feb 20, 2024
bf66953
Add thumbnail image
kevinneko Feb 21, 2024
238768c
Add support for thumbnailImage and action
kevinneko Feb 21, 2024
7aa797f
Clean code
kevinneko Feb 21, 2024
79d6caa
Reformat code
kevinneko Feb 21, 2024
ac539d6
Rename ActionContent
kevinneko Feb 21, 2024
c593130
Replace thumbnailImage type
kevinneko Feb 21, 2024
701198d
Add dismissOnTouchOutside control
kevinneko Feb 21, 2024
6db7a74
Add comment on CharcoalIdentifiableOverlayView
kevinneko Feb 21, 2024
63da0c1
Update CharcoalTooltip.swift
kevinneko Feb 21, 2024
b58fb42
Add SnackBar demo
kevinneko Feb 21, 2024
75c92ee
Replace thumbnail with charcoal logo
kevinneko Feb 21, 2024
0bf8e8e
Use @ViewBuilder
kevinneko Feb 21, 2024
5e534bb
Clean Code
kevinneko Feb 21, 2024
d9fbca4
Made code more readable
kevinneko Feb 21, 2024
bd664eb
Update ToastsView.swift
kevinneko Feb 21, 2024
0ead7e9
Add auto dismiss logic
kevinneko Feb 27, 2024
e1ee7c2
Fix dismiss comment
kevinneko Feb 27, 2024
388452d
Add Identifiable to CharcoalIdentifiableOverlayView
kevinneko Feb 27, 2024
7a84acf
Make all CharcoalPopupView identifiable
kevinneko Feb 27, 2024
e9744a8
Move all control logic into CharcoalPopupView
kevinneko Feb 27, 2024
0b09383
Reformat
kevinneko Feb 27, 2024
92bcc5a
Refine CharcoalOverlayContainerChild logic of updating view
kevinneko Feb 27, 2024
53e02b6
Rename to CharcoalOverlayUpdaterContainer
kevinneko Feb 27, 2024
e10a885
Add CharcoalToast
kevinneko Feb 27, 2024
c39ad76
Refine toast control
kevinneko Feb 27, 2024
fce7270
Refine screen edge of toast
kevinneko Feb 27, 2024
bdba4d3
Refine comments
kevinneko Feb 27, 2024
70417ba
Rename CharcoalPopupProtocol
kevinneko Feb 27, 2024
87a129c
Refine isActuallyPresenting logic
kevinneko Feb 27, 2024
6cf98c9
Clean animation
kevinneko Feb 27, 2024
c16d318
Add animation configuration
kevinneko Feb 27, 2024
edc2ea6
Add custom animation
kevinneko Feb 27, 2024
c939bc9
Add CharcoalToastProtocol
kevinneko Feb 28, 2024
b2ca18d
Makes CharcoalSnackBar adapt CharcoalToastProtocol
kevinneko Feb 28, 2024
d829f8f
Remove time delay
kevinneko Feb 28, 2024
db5466f
Refine SnackBar Animation logic
kevinneko Feb 28, 2024
5b39c79
Add CharcoalToastAnimationModifier
kevinneko Feb 28, 2024
a0e0992
Reformat code
kevinneko Feb 28, 2024
8412cd0
Update CharcoalPopupViewEdge of direction
kevinneko Feb 28, 2024
932ffae
Refine demo
kevinneko Feb 28, 2024
333503b
Fix missing animation
kevinneko Feb 28, 2024
fe42a48
Rename charcoalAnimatedToast to charcoalAnimatableToast
kevinneko Feb 28, 2024
ffeec3f
Rename CharcoalAnimatableToastProtocol
kevinneko Feb 28, 2024
be2a909
Rename for clean
kevinneko Feb 28, 2024
0093126
Simplify protocols
kevinneko Feb 28, 2024
18f4ade
Add drag control
kevinneko Mar 5, 2024
3d1b63c
Add Dismiss timer control logic
kevinneko Mar 5, 2024
48485f2
Refine drag damping logic
kevinneko Mar 5, 2024
023bfd9
Add CharcoalToastDraggable
kevinneko Mar 6, 2024
e3b8f46
Use CharcoalToastDraggableModifier on CharcoalSnackBar
kevinneko Mar 6, 2024
82b5c89
Format code
kevinneko Mar 6, 2024
44c462f
Add init structure
kevinneko Mar 12, 2024
8bbe79e
Add action button
kevinneko Mar 12, 2024
4fb12f7
Replace placeholder with ja text
kevinneko Mar 12, 2024
17e9376
Use CGPath union for iOS 16
kevinneko Mar 12, 2024
d145b7e
Update TooltipBubbleShape.swift
kevinneko Mar 12, 2024
0e475bc
Update CharcoalTooltip.swift
kevinneko Mar 12, 2024
cd032e0
Use GeometryReader on overlay
kevinneko Mar 12, 2024
a2b5f14
Use new path draw logic
kevinneko Mar 12, 2024
9851ca6
Refine arrow width
kevinneko Mar 12, 2024
5cc7b99
Refine arrow width
kevinneko Mar 13, 2024
3835ba9
Clean Code
kevinneko Mar 13, 2024
14f61fc
Refine preview
kevinneko Mar 13, 2024
ca5e9ca
Use timer instead of DispatchQueue
kevinneko Mar 13, 2024
597faf3
Refine layout logic
kevinneko Mar 13, 2024
996ea88
Refine arrow logic
kevinneko Mar 13, 2024
bb8cc96
Refine layout logic
kevinneko Mar 26, 2024
12bc105
Add missing charcoalOverlayContainer
kevinneko Mar 26, 2024
8e07941
Add Balloon to examples
kevinneko Mar 26, 2024
47eeb08
Add default tutorials
kevinneko Mar 26, 2024
a4060aa
Remove overlay when disappear
kevinneko Mar 26, 2024
42c85e2
Refine charcoalOverlayContainer place
kevinneko Mar 26, 2024
77d0aa6
Refine
kevinneko Mar 26, 2024
f708b1e
Update CharcoalSnackBar.swift
kevinneko Mar 26, 2024
9611aab
Add Charcoal Hint
kevinneko Mar 27, 2024
75e7b02
Use surface 3
kevinneko Mar 27, 2024
d4b5e24
Add isPresenting
kevinneko Mar 27, 2024
f911e75
Add hints to sample
kevinneko Mar 27, 2024
1b5c179
Format code
kevinneko Mar 27, 2024
4e67667
Init CharcoalTooltipView
kevinneko Apr 24, 2024
225c31e
Init Bubble shape
kevinneko Apr 24, 2024
51eff4a
Refine tooltip preview
kevinneko Apr 24, 2024
b658ce2
Rename as Charcoal Bubble Shape
kevinneko Apr 30, 2024
0073b9e
Add Label to tooltip
kevinneko Apr 30, 2024
15ffb14
Update text frame when traitCollection did change
kevinneko Apr 30, 2024
567de17
Update CharcoalTooltipView.swift
kevinneko Apr 30, 2024
6b1ae10
Add CharcoalTooltip
kevinneko Apr 30, 2024
ef1684c
Can debug show on method
kevinneko Apr 30, 2024
c7e60ae
Can layout point
kevinneko Apr 30, 2024
972e3b2
Can redraw target point
kevinneko Apr 30, 2024
1d0fb67
Update CharcoalTooltip.swift
kevinneko Apr 30, 2024
6f73f32
Refine tooltip display
kevinneko May 1, 2024
3efb6f3
Share the logic
kevinneko May 1, 2024
87ce7c2
Use interaction mode
kevinneko May 1, 2024
e0ba65e
Use CharcoalOverlayContainerView
kevinneko May 1, 2024
71bb979
Update CharcoalOverlay.swift
kevinneko May 1, 2024
8c5bf82
Refactor to ChacoalOverlayManager
kevinneko May 1, 2024
b391488
Makes CharcoalIdentifiableOverlayView Identifiable
kevinneko May 1, 2024
9586ce4
Refine layout logic
kevinneko May 1, 2024
a417758
Add display(view: CharcoalIdentifiableOverlayView)
kevinneko May 1, 2024
37cee23
Add tooltip to uikit example
kevinneko May 1, 2024
3c62e22
Update Tooltips.swift
kevinneko May 1, 2024
df2f52a
Add CharcoalIdentifiableOverlayDelegate
kevinneko May 1, 2024
ff1d909
Reformat
kevinneko May 1, 2024
dfe1553
Update StringExtension.swift
kevinneko May 1, 2024
a71477b
Add to UIKitSample
kevinneko May 1, 2024
479eaef
Merge branch 'main' into feat-swiftui-tooltip
kevinneko May 8, 2024
11c805a
Fix public requirements
kevinneko May 8, 2024
658afd5
Merge branch 'feat-swiftui-tooltip' into feat-uikit-tooltip
kevinneko May 8, 2024
6d1c039
Reformat
kevinneko May 8, 2024
9dcdb2c
Use touch began to handle dismiss on touch
kevinneko May 8, 2024
7708f10
Update CharcoalIdentifiableOverlayView.swift
kevinneko May 8, 2024
f033646
Merge branch 'feat-swiftui-tooltip' into feat-swiftui-toast
kevinneko May 8, 2024
d9acdfb
Merge branch 'feat-uikit-tooltip' into feat-uikit-toast
kevinneko May 14, 2024
67a9672
Add CharcoalToastView
kevinneko May 14, 2024
03b5735
change cornerRadius
kevinneko May 14, 2024
4ccd046
Add CharcoalToast
kevinneko May 15, 2024
752ba6d
Move show logic out
kevinneko May 15, 2024
1f10419
Reformat
kevinneko May 15, 2024
e0231f0
Refine dismiss method
kevinneko May 15, 2024
144e132
Merge branch 'feat-uikit-tooltip' into feat-uikit-toast
kevinneko May 15, 2024
a8cde5d
Update CharcoalToast.swift
kevinneko May 15, 2024
f75fb7a
Add ActionContent and ActionComplete callback
kevinneko May 15, 2024
818db64
Merge branch 'feat-uikit-tooltip' into feat-uikit-toast
kevinneko May 15, 2024
6b6bd1a
Update CharcoalToast.swift
kevinneko May 15, 2024
0f18ca5
Update CharcoalBubbleShape_UIKit.swift
kevinneko May 15, 2024
c9f9d4f
Merge branch 'feat-uikit-tooltip' into feat-uikit-toast
kevinneko May 15, 2024
fd50bc3
Refine layout animation logic
kevinneko May 15, 2024
e203f76
Refine animation
kevinneko May 15, 2024
0ebb974
Add dismiss
kevinneko May 15, 2024
56d9243
Add example
kevinneko May 15, 2024
72f12b0
Reformat
kevinneko May 15, 2024
eb25b09
Add toasts example
kevinneko May 15, 2024
d6a4577
Add CharcoalSnackBarView
kevinneko May 28, 2024
beed8a7
Update project.pbxproj
kevinneko May 28, 2024
ef5f9d7
Clean code
kevinneko May 28, 2024
23b6c01
Refine layout logic
kevinneko May 28, 2024
95ccac0
Add CharcoalSnackBar
kevinneko May 28, 2024
90fbeb5
Update CharcoalSnackBar.swift
kevinneko May 28, 2024
639a46e
Update CharcoalSnackBar.swift
kevinneko May 28, 2024
7a06da4
Refine layout logic
kevinneko May 28, 2024
9ff4f22
Refine toasts text
kevinneko May 28, 2024
b5256e1
Update CharcoalToastDraggableModifier.swift
kevinneko May 28, 2024
eb59f4f
Add CharcoalRubberGesture
kevinneko May 29, 2024
5773c8d
use id to notify did dismiss
kevinneko May 29, 2024
e14e161
Add rubber gesture
kevinneko May 29, 2024
ac6f35c
Refactor
kevinneko May 29, 2024
9b03460
Refactor
kevinneko May 29, 2024
5355834
Fix memory leak
kevinneko May 29, 2024
6167fb7
Format
kevinneko May 29, 2024
85dba89
Fix memory leak
kevinneko May 29, 2024
d153e95
Add example
kevinneko May 29, 2024
2c346f3
Refine snackbar
kevinneko May 29, 2024
dde2404
Merge branch 'main' into feat-swiftui-tooltip
kevinneko May 30, 2024
a2e52b9
Merge branch 'main' into feat-swiftui-tooltip
kevinneko May 30, 2024
e55d4f0
Merge branch 'feat-swiftui-tooltip' into feat-uikit-tooltip
kevinneko May 30, 2024
c185ec5
Merge branch 'feat-uikit-tooltip' into feat-swiftui-toast
kevinneko May 31, 2024
3a1cb2b
Merge branch 'feat-swiftui-toast' into feat-uikit-toast
kevinneko May 31, 2024
33ec9d0
Merge branch 'feat-uikit-toast' into feat-swiftui-hint
kevinneko May 31, 2024
fb2cb70
Refine swift lint
kevinneko May 31, 2024
a573a8b
Refactor CharcoalToastView
kevinneko May 31, 2024
4bf3208
Refactor CharcoalSnackBarView
kevinneko May 31, 2024
397ebec
Reformat
kevinneko May 31, 2024
2c5dd37
Refine self logic
kevinneko May 31, 2024
6333a45
Merge branch 'feat-uikit-toast' into feat-swiftui-hint
kevinneko Jun 4, 2024
f535373
Merge branch 'main' into feat-swiftui-hint
kevinneko Oct 9, 2024
962da31
Delete スクリーンショット 2024-02-21 17.28.10.png
kevinneko Oct 9, 2024
0efc40a
Remove duplicated balloons
kevinneko Oct 9, 2024
2eb7e8e
Delete スクリーンショット 2024-02-21 17.28.10.png
kevinneko Oct 9, 2024
f79b9cb
Clean extensions
kevinneko Oct 9, 2024
6335224
Clean CharcoalRubberGesture
kevinneko Oct 9, 2024
d998317
Delete ConditionalViewModifier.swift
kevinneko Oct 9, 2024
5517189
Refactor Preview
kevinneko Oct 9, 2024
02c49eb
Merge branch 'main' into feat-swiftui-hint
kevinneko Oct 15, 2024
b4f8997
Fix h spacing
kevinneko Oct 15, 2024
907b913
Fix info16 icon
kevinneko Oct 15, 2024
86f0203
Use CharcoalAction
kevinneko Oct 15, 2024
697f5a7
Reformat
kevinneko Oct 15, 2024
a816c95
Omit trailing closure
kevinneko Oct 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public struct ContentView: View {
NavigationLink(destination: ToastsView().charcoalOverlayContainer()) {
Text("Toasts")
}
NavigationLink(destination: HintsView()) {
Text("Hints")
}
NavigationLink(destination: SpinnersView()) {
Text("Spinners")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import Charcoal
import SwiftUI

public struct HintsView: View {
@State var isPresented = true

@State var isPresented2 = true

@State var isPresented3 = true

public var body: some View {
ScrollView {
VStack {
CharcoalHint(text: "ヒントテキストヒントテキスト", isPresenting: $isPresented) {
Button(action: {
isPresented = false
}) {
Text("Button")
}
}

CharcoalHint(text: "ヒントテキストヒントテキスト", isPresenting: $isPresented2)

CharcoalHint(text: "ヒントテキストヒントテキスト", maxWidth: .infinity, isPresenting: $isPresented3)
}
.padding()
}
.navigationBarTitle("Hints")
}
}

#Preview {
HintsView()
}
7 changes: 0 additions & 7 deletions Sources/CharcoalShared/Extensions/CGSize+Extension.swift

This file was deleted.

87 changes: 87 additions & 0 deletions Sources/CharcoalSwiftUI/Components/Hint/CharcoalHint.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import SwiftUI

public struct CharcoalHint<ActionContent: View>: View {
/// The text of the tooltip
let text: String

/// The text of the tooltip
let subtitle: String?

let icon: CharcoalAsset.Images

/// The corner radius of the tooltip
let cornerRadius: CGFloat = 8

let maxWidth: CGFloat?

/// A binding to whether the overlay is presented.
@Binding var isPresenting: Bool

let action: ActionContent?

@State var timer: Timer?

public init(
text: String,
subtitle: String? = nil,
icon: CharcoalAsset.Images = .info16,
kvvzr marked this conversation as resolved.
Show resolved Hide resolved
maxWidth: CGFloat? = nil,
isPresenting: Binding<Bool>,
@ViewBuilder action: () -> ActionContent? = { EmptyView() }
) {
self.text = text
self.subtitle = subtitle
self.icon = icon
self.maxWidth = maxWidth
_isPresenting = isPresenting
self.action = action()
}

public var body: some View {
if isPresenting {
HStack(spacing: 5) {
kvvzr marked this conversation as resolved.
Show resolved Hide resolved
Image(charocalIcon: icon)

VStack {
Text(text).charcoalTypography14Regular()
if let subtitle = subtitle {
Text(subtitle).charcoalTypography14Regular()
}
}

if let action = action, type(of: action) != EmptyView.self {
kvvzr marked this conversation as resolved.
Show resolved Hide resolved
Spacer()
action.charcoalPrimaryButton(size: .small)
}
}
.frame(maxWidth: maxWidth)
.padding(EdgeInsets(top: 12, leading: 16, bottom: 12, trailing: 16))
.background(charcoalColor: .surface3)
.cornerRadius(cornerRadius, corners: .allCorners)
}
}
}

@available(iOS 17, *)
#Preview {
@Previewable @State var isPresenting = true
@Previewable @State var isPresenting2 = true
@Previewable @State var isPresenting3 = true

@Previewable @State var textOfLabel = "Hello"

VStack {
CharcoalHint(text: "ヒントテキストヒントテキスト", isPresenting: $isPresenting) {
Button(action: {
isPresenting = false
}) {
Text("Button")
}
}

CharcoalHint(text: "ヒントテキストヒントテキスト", isPresenting: $isPresenting2)

CharcoalHint(text: "ヒントテキストヒントテキスト", maxWidth: .infinity, isPresenting: $isPresenting3)

}.padding()
}
Loading