Skip to content

Commit

Permalink
Merge pull request #7 from c-villain/fix-Bubble-initializer
Browse files Browse the repository at this point in the history
change visibility for inits
  • Loading branch information
c-villain authored May 17, 2023
2 parents 8084c53 + cbc4fce commit 4f44259
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 15 deletions.
20 changes: 16 additions & 4 deletions Sources/Shapes/CustomShapes/Bubbles/Bubble.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,23 @@ public enum TailPosition {

public struct Bubble: Shape {

var type: MessageType = .send
var cornerRadius: CGFloat = 0.0
var type: MessageType
var cornerRadius: CGFloat

var tail: (width: CGFloat, height: CGFloat) = (6, 17)
var tailPosition: TailPosition = .bottom
var tail: (width: CGFloat, height: CGFloat)
var tailPosition: TailPosition

public init(
type: MessageType = .send,
cornerRadius: CGFloat = 0.0,
tail: (width: CGFloat, height: CGFloat) = (6, 17),
tailPosition: TailPosition = .bottom
) {
self.type = type
self.cornerRadius = cornerRadius
self.tail = tail
self.tailPosition = tailPosition
}

public func path(in rect: CGRect) -> Path {
switch (type, tailPosition) {
Expand Down
12 changes: 10 additions & 2 deletions Sources/Shapes/CustomShapes/Diamond.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@ import SwiftUI

public struct Diamond: Shape {

var top: CGPoint = .init(x: 0, y: 0)
var bottom: CGPoint = .init(x: 0, y: 0)
var top: CGPoint
var bottom: CGPoint

public init(
top: CGPoint = .init(x: 0, y: 0),
bottom: CGPoint = .init(x: 0, y: 0)
) {
self.top = top
self.bottom = bottom
}

public func path(in rect: CGRect) -> Path {
Path { path in
Expand Down
22 changes: 17 additions & 5 deletions Sources/Shapes/CustomShapes/RoundedRectangle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,23 @@ import SwiftUI
public struct RoundedRectangle: Shape {

// corner radiuses:
var topLeft: CGFloat = 0
var topRight: CGFloat = 0
var bottomLeft: CGFloat = 0
var bottomRight: CGFloat = 0

var topLeft: CGFloat
var topRight: CGFloat
var bottomLeft: CGFloat
var bottomRight: CGFloat

public init(
topLeft: CGFloat = 0,
topRight: CGFloat = 0,
bottomLeft: CGFloat = 0,
bottomRight: CGFloat = 0
) {
self.topLeft = topLeft
self.topRight = topRight
self.bottomLeft = bottomLeft
self.bottomRight = bottomRight
}

public func path(in rect: CGRect) -> Path {

Path { path in
Expand Down
20 changes: 16 additions & 4 deletions Sources/Shapes/CustomShapes/Wave.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,24 @@ import SwiftUI

public struct Wave: Shape {

var corner: CGFloat = 0 // for corner radius
var height: CGFloat = 25 // height of wave
var corner: CGFloat // for corner radius
var height: CGFloat // height of wave

//for wave:
var startX: CGFloat = 180
var length: CGFloat = 120
var startX: CGFloat
var length: CGFloat

public init(
corner: CGFloat = 0,
height: CGFloat = 25,
startX: CGFloat = 180,
length: CGFloat = 120
) {
self.corner = corner
self.height = height
self.startX = startX
self.length = length
}

public var animatableData: CGFloat {
get { startX }
Expand Down

0 comments on commit 4f44259

Please sign in to comment.