Merge pull request #7 from c-villain/fix-Bubble-initializer change visibility for inits
Merge pull request #7 from c-villain/fix-Bubble-initializer
change visibility for inits
Different shapes on pure SwiftUI
👨🏻💻 Feel free to subscribe to channel SwiftUI dev in telegram.
To integrate Shapes into your project using SwiftPM add the following to your Package.swift:
Shapes
Package.swift
dependencies: [ .package(url: "https://github.com/c-villain/Shapes", from: "0.1.0"), ],
or via XcodeGen insert into your project.yml:
project.yml
name: YourProjectName options: deploymentTarget: iOS: 13.0 packages: Shapes: url: https://github.com/c-villain/Shapes from: 0.1.0 targets: YourTarget: type: application ... dependencies: - package: Shapes
All examples you can find in demo project inside package.
There are different custom shapes provided by Shapes.
👇🏻 Tap on its name to see description and example of using.
RoundedRectangle shape and .cornerRadius modifier is used to round specific corners:
RoundedRectangle
.cornerRadius
Use such way:
RoundedRectangle(topLeft: 0, topRight: 16, bottomLeft: 16, bottomRight: 16)
If you have radiuses on one side that larger than half of height or half of width:
then use chain of modifiers:
Text("Corner radius modifier") .foregroundColor(.black) .padding(16) .background ( Color.purple .cornerRadius(200, corners: .topLeft) .cornerRadius(200, corners: .bottomLeft) )
Bubble shape and .bubble modifier is used to draw messages or tips:
Bubble
.bubble
VStack { Text("Hi!") .padding(.horizontal, 12) .padding(.vertical, 8) .background( Bubble.init(type: .send, cornerRadius: 20, tail: (width: 6, height: 15)) .stroke(.gray, lineWidth: 2) ) .frame(maxWidth: .infinity, alignment: .trailing) Text("Wassup!") .padding(.horizontal, 12) .padding(.vertical, 8) .background( Bubble.init(type: .received, cornerRadius: 20, tail: (width: 6, height: 15)) .stroke(.gray, lineWidth: 2) ) .frame(maxWidth: .infinity, alignment: .leading) } .padding(20)
or via modifier:
VStack(spacing: 20) { Text("Custom bubble ✌🏻 \nLeading") .foregroundColor(.white) .padding(16) .bubble(.received, withStroke: .clear, lineWidth: 2, fill: .black.opacity(0.7)) .frame(maxWidth: .infinity, alignment: .leading) Text("Custom bubble ✌🏻\nTrailing") .foregroundColor(.white) .padding(16) .bubble(.send, withStroke: .clear, lineWidth: 2, fill: LinearGradient( gradient: Gradient(colors: [.blue.opacity(0.9), .blue.opacity(0.6)]), startPoint: .leading, endPoint: .trailing )) .frame(maxWidth: .infinity, alignment: .trailing) }
Wave shape and .waved modifier is used to draw animated wave:
Wave
.waved
HStack { ... /* Buttons */ ... } .background( Color.black.opacity(0.8) .waved(corner: cornerRadius, height: waveHeight, startX: waveX, length: waveLength) )
Diamond shape and .diamond modifier is used to draw rhombuses or quadrangles:
Diamond
.diamond
Text("Diamond") .padding(.horizontal, 24) .padding(.vertical, 16) .background( Diamond() .stroke(.blue, lineWidth: 2) )
Text("Diamond modifier") .foregroundColor(.black) .padding(24) .diamond(top: .init(x: 40, y: 0), bottom: .init(x: 0, y: 0), withStroke: .black, lineWidth: 2.0, fill: .yellow)
Shapes package is released under an MIT license.
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
Shapes
Different shapes on pure SwiftUI
👨🏻💻 Feel free to subscribe to channel SwiftUI dev in telegram.
Requirements
Installation
Swift Package Manager
To integrate
Shapes
into your project using SwiftPM add the following to yourPackage.swift
:or via XcodeGen insert into your
project.yml
:Quick start
All examples you can find in demo project inside package.
There are different custom shapes provided by
Shapes
.👇🏻 Tap on its name to see description and example of using.
CornerRadius
RoundedRectangle
shape and.cornerRadius
modifier is used to round specific corners:Use such way:
If you have radiuses on one side that larger than half of height or half of width:
then use chain of modifiers:
Bubble
Bubble
shape and.bubble
modifier is used to draw messages or tips:Use such way:
or via modifier:
Wave
Wave
shape and.waved
modifier is used to draw animated wave:Use such way:
Diamond
Diamond
shape and.diamond
modifier is used to draw rhombuses or quadrangles:Use such way:
or via modifier:
Communication
License
Shapes package is released under an MIT license.