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 UIKit Toast #250

Merged
merged 196 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 187 commits
Commits
Show all changes
196 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
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
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
c64c04d
Merge branch 'main' into feat-swiftui-toast
kevinneko Jul 10, 2024
4229a9c
Reformat
kevinneko Jul 10, 2024
4247dd2
Fix name
kevinneko Jul 10, 2024
89bef76
Merge branch 'main' into feat-swiftui-toast
kevinneko Jul 10, 2024
a89bf66
Fix geometry
kevinneko Jul 10, 2024
ae59b41
Revert "Fix geometry"
kevinneko Jul 10, 2024
d55ed42
Fix proxy name
kevinneko Jul 10, 2024
2a603dc
Adjust unused text
kevinneko Jul 10, 2024
e823b5b
Replace charcoal logo
kevinneko Jul 23, 2024
fa577b1
Remove conditional modifier
kevinneko Jul 23, 2024
84cdc67
Add default dismiss time to toasts
kevinneko Jul 23, 2024
716fa66
Reformat
kevinneko Jul 23, 2024
0e0a738
Merge branch 'feat-swiftui-toast' into feat-uikit-toast
kevinneko Jul 23, 2024
85d43b6
Merge branch 'main' into feat-uikit-toast
kevinneko Jul 23, 2024
b7d5a05
Merge branch 'main' into feat-uikit-toast
kevinneko Jul 24, 2024
588a957
Fix logo image
kevinneko Jul 24, 2024
626b639
Move imageWithColor out of shared
kevinneko Aug 6, 2024
20cc7eb
Refine toast with action callback
kevinneko Aug 6, 2024
8b45804
Clean code
kevinneko Aug 6, 2024
06200f8
Refine toasts looking
kevinneko Aug 6, 2024
9ec9655
Reformat
kevinneko Aug 6, 2024
63d534a
Update CharcoalToast.swift
kevinneko Aug 6, 2024
81bbd9d
Refine gesture animator
kevinneko Aug 6, 2024
1e3cfc3
Rename toast as snackbar
kevinneko Aug 6, 2024
072eed8
Remove deinit
kevinneko Aug 7, 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
2 changes: 1 addition & 1 deletion .swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
--wraparguments before-first
--wrapcollections before-first

--exclude Sources/Charcoal/Generated
--exclude Sources/CharcoalShared/Generated
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public final class ContentViewController: UIViewController {
case typographies = "Typographies"
case icons = "Icons"
case tooltips = "Tooltips"
case toasts = "Toasts"
case spinners = "Spinners"

var viewController: UIViewController {
Expand All @@ -68,6 +69,8 @@ public final class ContentViewController: UIViewController {
return TextFieldsViewController()
case .tooltips:
return TooltipsViewController()
case .toasts:
return ToastsViewController()
case .spinners:
return SpinnersViewController()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "charcoal-logo.png",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ final class ButtonsViewController: UIViewController {
return view
}()

let cellReuseIdentifier = "cell"

private var buttons: [ButtonExample] = [
// Primary
ButtonExample(title: "Primary Button M", buttonStyle: CharcoalPrimaryMButton.self, isEnabled: true),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
import Charcoal
import UIKit

enum SnackbarTitles: String, CaseIterable {
case normal = "Normal"
case withAction = "with Action"
case withActionAndThumbnail = "with Action and Thumbnail"

var text: String {
return "ブックマークしました"
}

func configCell(cell: UITableViewCell) {
cell.textLabel!.text = "SnackBar"
cell.detailTextLabel?.text = rawValue
}
}

enum ToastsTitles: String, CaseIterable {
kevinneko marked this conversation as resolved.
Show resolved Hide resolved
case top = "Top"
case bottom = "Bottom"
case multiline = "Multiline"

var text: String {
switch self {
case .top:
return "Hello World"
case .bottom:
return "Hello World This is a tooltip with mutiple line"
case .multiline:
return "こんにちは This is a tooltip and here is testing it's multiple line feature"
}
}

func configCell(cell: UITableViewCell) {
cell.textLabel!.text = rawValue
}
}

public final class ToastsViewController: UIViewController {
private lazy var tableView: UITableView = {
let view = UITableView(frame: .zero, style: .insetGrouped)
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()

let cellReuseIdentifier = "cell"

private enum Sections: Int, CaseIterable {
case toasts
case snackbars

var title: String {
switch self {
case .toasts:
return "Toasts"
case .snackbars:
return "Snackbars"
}
}

var items: [any CaseIterable] {
switch self {
case .toasts:
return ToastsTitles.allCases
case .snackbars:
return SnackbarTitles.allCases
}
}
}

override public func viewDidLoad() {
super.viewDidLoad()
setupNavigationBar()
setupUI()
}

private func setupNavigationBar() {
navigationItem.title = "Charcoal"
}

private func setupUI() {
view.addSubview(tableView)

NSLayoutConstraint.activate([
tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
tableView.topAnchor.constraint(equalTo: view.topAnchor),
tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
])

tableView.dataSource = self
tableView.delegate = self
}
}

extension ToastsViewController: UITableViewDelegate, UITableViewDataSource {
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let section = Sections.allCases[indexPath.section]

let cell = tableView.dequeueReusableCell(withIdentifier: cellReuseIdentifier) as UITableViewCell? ?? UITableViewCell(style: .subtitle, reuseIdentifier: cellReuseIdentifier)

switch section {
case .toasts:
let titleCase = ToastsTitles.allCases[indexPath.row]
titleCase.configCell(cell: cell)
return cell
case .snackbars:
let titleCase = SnackbarTitles.allCases[indexPath.row]
titleCase.configCell(cell: cell)
return cell
}
}

public func tableView(_: UITableView, numberOfRowsInSection section: Int) -> Int {
return Sections.allCases[section].items.count
}

public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)

let section = Sections.allCases[indexPath.section]

switch section {
case .toasts:
let titleCase = ToastsTitles.allCases[indexPath.row]

var toastID: CharcoalIdentifiableOverlayView.IDValue
switch titleCase {
case .top:
toastID = CharcoalToast.show(text: titleCase.text, screenEdge: .top)
case .bottom:
toastID = CharcoalToast.show(text: titleCase.text, appearance: .error, screenEdge: .bottom)
case .multiline:
toastID = CharcoalToast.show(text: titleCase.text, screenEdge: .bottom)
}

DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
CharcoalToast.dismiss(id: toastID)
}
case .snackbars:
let titleCase = SnackbarTitles.allCases[indexPath.row]

var toastID: CharcoalIdentifiableOverlayView.IDValue
switch titleCase {
case .normal:
toastID = CharcoalSnackBar.show(text: titleCase.text, screenEdge: .top)
case .withAction:
toastID = CharcoalSnackBar.show(text: titleCase.text, screenEdge: .bottom, action: CharcoalAction(title: "編集", actionCallback: {
print("Tapped 編集")
}))
case .withActionAndThumbnail:
toastID = CharcoalSnackBar.show(text: titleCase.text, thumbnailImage: UIImage(named: "SnackbarDemo", in: Bundle.module, with: nil), screenEdge: .bottom, action: CharcoalAction(title: "編集", actionCallback: {
print("Tapped 編集")
}))
}

DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
CharcoalSnackBar.dismiss(id: toastID)
}
}
}

public func numberOfSections(in tableView: UITableView) -> Int {
return Sections.allCases.count
}

public func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return Sections.allCases[section].title
}
}

@available(iOS 17.0, *)
#Preview {
let viewController = ToastsViewController()
return viewController
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
24651B2727043658005AD842 /* Sources */,
24651B2827043658005AD842 /* Frameworks */,
24651B2927043658005AD842 /* Resources */,
242CCCD62771748B00897251 /* SwiftLint */,
9F0036972C0A0399003BE2C2 /* SwiftLint */,
);
buildRules = (
);
Expand Down Expand Up @@ -141,7 +141,7 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
242CCCD62771748B00897251 /* SwiftLint */ = {
9F0036972C0A0399003BE2C2 /* SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
Expand Down
15 changes: 15 additions & 0 deletions Sources/CharcoalShared/Enums/CharcoalPopupViewEdge.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Foundation

public enum CharcoalPopupViewEdge {
case top
case bottom

public var direction: CGFloat {
switch self {
case .top:
return 1
case .bottom:
return -1
}
}
}
13 changes: 13 additions & 0 deletions Sources/CharcoalShared/Enums/CharcoalToastAppearance.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public enum CharcoalToastAppearance {
case success
case error

public var background: ColorAsset.Color {
switch self {
case .success:
return CharcoalAsset.ColorPaletteGenerated.success.color
case .error:
return CharcoalAsset.ColorPaletteGenerated.assertive.color
}
}
}
11 changes: 11 additions & 0 deletions Sources/CharcoalShared/Extensions/UIColor+Extension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import UIKit

public extension UIColor {
kevinneko marked this conversation as resolved.
Show resolved Hide resolved
func imageWithColor(width: Int, height: Int) -> UIImage {
let size = CGSize(width: width, height: height)
return UIGraphicsImageRenderer(size: size).image { rendererContext in
self.setFill()
rendererContext.fill(CGRect(origin: .zero, size: size))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import SwiftUI

typealias CharcoalPopupProtocol = Equatable & Identifiable & View

public enum CharcoalPopupViewEdge {
case top
case bottom

extension CharcoalPopupViewEdge {
var alignment: Alignment {
switch self {
case .top:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,6 @@ public extension View {
}
}

private extension UIColor {
func imageWithColor(width: Int, height: Int) -> UIImage {
let size = CGSize(width: width, height: height)
return UIGraphicsImageRenderer(size: size).image { rendererContext in
self.setFill()
rendererContext.fill(CGRect(origin: .zero, size: size))
}
}
}

private struct SnackBarsPreviewView: View {
@State var isPresenting = true
Expand Down
16 changes: 1 addition & 15 deletions Sources/CharcoalSwiftUI/Components/Toast/CharcoalToast.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct CharcoalToast<ActionContent: View>: CharcoalPopupProtocol, CharcoalToastB
.padding(EdgeInsets(top: 8, leading: 24, bottom: 8, trailing: 24))
}
.background(
appearance.background
Color(appearance.background)
)
.charcoalAnimatableToast(
isPresenting: $isPresenting,
Expand Down Expand Up @@ -110,20 +110,6 @@ struct PopupViewSizeKey: PreferenceKey {
static var defaultValue: CGSize = .zero
}

public enum CharcoalToastAppearance {
case success
case error

var background: Color {
switch self {
case .success:
return Color(CharcoalAsset.ColorPaletteGenerated.success.color)
case .error:
return Color(CharcoalAsset.ColorPaletteGenerated.assertive.color)
}
}
}

public struct CharcoalToastAnimationConfiguration {
public let enablePositionAnimation: Bool
public let animation: Animation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct CharcoalToastDraggableModifier: ViewModifier, CharcoalToastDraggable {
height: gesture.translation.height
)
} else {
// the less the faster resistance
// Rubber band effect
let limit: CGFloat = 60
let yOff = gesture.translation.height
let dist = sqrt(yOff * yOff)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ extension ChacoalOverlayManager {
// MARK: - CharcoalIdentifiableOverlayDelegate

extension ChacoalOverlayManager: CharcoalIdentifiableOverlayDelegate {
func overlayViewDidDismiss(_ overlayView: CharcoalIdentifiableOverlayView) {
overlayContainerViews = overlayContainerViews.filter { $0.id != overlayView.id }
func overlayViewDidDismiss(_ overlayID: CharcoalIdentifiableOverlayView.ID) {
overlayContainerViews = overlayContainerViews.filter { $0.id != overlayID }
if overlayContainerViews.isEmpty {
removeBackground()
}
Expand Down
Loading
Loading