• Stars
    star
    117
  • Rank 301,828 (Top 6 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 4 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Loading Animation Button for SwiftUI

Project logo

๐Ÿ”„ SwiftUI LoadingButton ๐Ÿ”„

License Release


Simple Loading Animation Button for SwiftUI

๐Ÿ“น Preview

๐Ÿ Getting Started

Requirements

  • Xcode 11+
  • SwiftUI
  • iOS 14+
  • macOS 10.15+

Installaion

Swift Package Manager(SPM)

File โžœ Swift Packages โžœ Add Package Dependancy..
.package(url: "https://github.com/Changemin/LoadingButton", from: "1.1.2")

๐ŸŽˆUsage

LoadingButton(action: { }, isLoading: <Binding>Bool, style: LoadingButtonStyle) {
    // View on the button
    // style is optional parameter
  • action : Actions to do when button clicked
  • isLoading : <Binding>Bool type. you can control loading status with this.
  • style(Optional) : Custom style with LoadingButtonStyle

๐Ÿ› Custom Modifiers

LoadingButtonStyle(width: CGFloat, 
                   height: CGFloat,
                   cornerRadius: CGFloat,
                   backgroundColor: Color,
                   loadingColor: Color,
                   strokeWidth: CGFloat,
                   strokeColor: Color)

// All of the parameter is optional
  • width(Optional) : Width of button
  • height(Optional) : Height of button
  • cornerRadius(Optional) : Corner radius of button
  • backgroundColor(Optional) : Background color of button
  • loadingColor(Optional) : Background color of button when Loading, default is 50% opacity of backgroundColor
  • strokeWidth(Optional) : Circle loading indicator stroke width
  • strokeColor(Optional) : Circle loading indicator stroke Color(default: gray)

Example

๐Ÿ‘ถ Simple

import SwiftUI
import LoadingButton

struct ContentView: View {
    @State var isLoading: Bool = false
    
    var body: some View {
        LoadingButton(action: {
            // Your Action here
        }, isLoading: $isLoading) {
            Text("LoadingButton").foregroundColor(Color.white)
        }
    }
}

Result

๐Ÿ’…๐Ÿป Applying Fully Custom Style

import SwiftUI
import LoadingButton

struct ContentView: View {
    @State var isLoading: Bool = false
    var style = LoadingButtonStyle(width: 312,
                              height: 54,
                              cornerRadius: 27,
                              backgroundColor: .orange,
                              loadingColor: Color.orange.opacity(0.5),
                              strokeWidth: 5,
                              strokeColor: .gray)
    
    var body: some View {
        LoadingButton(action: {
            // Your Action here
        }, isLoading: $isLoading, style: style) {
            Text("Styled LoadingButton").foregroundColor(Color.white)
        }
    }
}

Result

๐Ÿ’…๐Ÿป Styling Only Needs

import SwiftUI
import LoadingButton

struct ContentView: View {
    @State var isLoading: Bool = false
    
    var body: some View {
        LoadingButton(action: {
            // Your Action here
        }, isLoading: $isLoading, style: LoadingButtonStyle(cornerRadius: 27, backgroundColor: .orange)) {
            Text("Styled LoadingButton").foregroundColor(Color.white)
        }
    }
}

Same Result

โœ… TODO

  • End animation(normal, shake(when fail), expand)
  • Support gradient background color

๐Ÿ“œ License

LoadingButton is available under the MIT license. See the LICENSE file for more info.

โœ๏ธ Author

More Repositories

1

TagField

๐Ÿท Simple Tag Field for SwiftUI
Swift
23
star
2

PressableButton

๐Ÿ•นPressing Animation & Haptic Feedback SwiftUI Button
Swift
19
star
3

FloatingTextField

๐ŸŒฌ Simple and Animated TextField for SwiftUI
Swift
10
star
4

DynamicPortfolio

๋ฐฐ์šฐ๋ฉด์„œ ๋งŒ๋“œ๋Š” ๋ฆฌ์•กํŠธ ํฌํŠธํด๋ฆฌ์˜ค(์‘์šฉํ”„๋กœ๊ทธ๋ž˜๋ฐํ™”๋ฉด๊ตฌํ˜„ ์ˆ˜ํ–‰ํ‰๊ฐ€)
JavaScript
7
star
5

eBook-maker

๐Ÿค–python์„ ํ™œ์šฉํ•ด ์‹œ์ง‘๋งŒ๋“ค๊ธฐ ๋…ธ๊ฐ€๋‹ค๋ฅผ ๋Œ€์‹ ํ•ด์ค„ eBook-maker
Python
6
star
6

useMOuse-consoleGame

๐Ÿ–ฑ๏ธ๋งˆ์šฐ์Šค๋ฅผ ๊ทน๋„๋กœ ํ™œ์šฉํ•˜๋ผ! ๋””๋ฏธ๊ณ  ์ฝ˜์†”๊ฒŒ์ž„ ์ˆ˜ํ–‰ํ‰๊ฐ€ useMOuse๐Ÿญ
C
5
star
7

swift-hiragana-training

2020.4.12 / SwiftUI ์ฒซ ์ž…๋ฌธ ํ”„๋กœ์ ํŠธ
Swift
4
star
8

HTML-portfolio-example

List Of What I Learned. ์ผ์ฃผ์ผ๊ฐ„ ๋ฐฐ์šด๊ฒƒ์„ ์ •๋ฆฌํ•ด๋ณด์ž.
HTML
4
star
9

RadioGroup

๐Ÿ—ณ Radio Group Supports Generic Type of Value for SwiftUI
Swift
4
star
10

zoom-auto-participate

๐Ÿ‘จโ€๐Ÿซauto zoom meeting attend at specific time
Python
3
star
11

AppInventer_1ManPingPong

์•ฑ์ธ๋ฒคํ„ฐ๋กœ ์ œ์ž‘ํ•œ 1์ธ ํ•‘ํ๊ฒŒ์ž„
3
star
12

MiseAlio

(๋””๋ฏธ๊ณ  ํŠน๋ณ„์ „ํ˜• ์‹ค์ ๋ฌผ)Arduino์™€ Rest API๋ฅผ ํ™œ์šฉํ•œ ๋ฏธ์„ธ๋จผ์ง€ ์‹ ํ˜ธ๋“ฑ MiseAlio
C++
3
star
13

ko-highschool-logo

๐ŸŽ’ ์ „๊ตญ ๊ณ ๋“ฑํ•™๊ต ๋กœ๊ณ ๋ฅผ ํฌ๋กค๋งํ•ด๋ณด์ž
Python
3
star
14

SegmentDisplay

๐Ÿ“Ÿ 7 Segment Display in SwiftUI
Swift
3
star
15

Luminous

2019๋…„ ๋””๋ฏธ๊ณ  ํ•ด์ปคํ†ค ๊ธˆ์ƒ-์•ˆ๊ตฌ์ œ์Šค์ณ์ธ์‹ ๋…์„œ๋ณด์กฐ๋„๊ตฌ Luminous
Python
2
star
16

eye-blink-game

๐Ÿ˜ฃPython์„ ํ™œ์šฉํ•œ ๋ˆˆ๐Ÿ‘€ ๋งŽ์ด ๊นœ๋ฐ•์ด๊ธฐ ๊ฒŒ์ž„๐Ÿ˜ฒ
Python
2
star
17

VRedu-web

์‚ผ์„ฑSDS/JA ์Šค๋งˆํŠธ ํ•ด์ปคํ†ค - VRedu ์›น
HTML
2
star
18

esp-firebase-toggle

2019 AngelHack hackathon์•„์ด๋””์–ด-ARAI, Arduinoํ† ๊ธ€ ๋ฐฉ์‹์˜ ์Šค์œ„์น˜
C++
2
star
19

word-remind-chatbot

๐Ÿ‘ผ๐Ÿผ๋‹จ์–ด ์ฑ—๋ด‡ '์™€์ด์ฆˆ'์™€ ํ•จ๊ป˜ ๋‹จ์–ด๋ฅผ ํšจ์œจ์ ์œผ๋กœ ์™ธ์›Œ๋ณด์ž!๐Ÿ‘ผ๐Ÿผ
Python
1
star
20

invisible-stopwatch

๋‚˜๋ฅผ ๋ฐฉํ•ดํ•˜์ง€ ์•Š๋Š” ์Šคํ†ฑ์›Œ์น˜(๊ณต์—…์ผ๋ฐ˜ ํ”„๋กœ์ ํŠธ)
Swift
1
star
21

Cake-hardware

๐Ÿฐ(์ฐฝ์˜IT๊ณต๋ชจ์ „)๋””๋ฏธ๊ณ  ์‹ค ์‚ฌ์šฉ ์˜ˆ์•ฝ ์„œ๋น„์Šค CAKE ํ•˜๋“œ์›จ์–ด
C++
1
star
22

cpp-algorithm-study

c++ ์ž๋ฃŒ๊ตฌ์กฐ์™€ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ณต๋ถ€(๋Š” ์•ˆํ•˜๋Š”์ค‘..)
1
star
23

photo.kyungmin.life

my 24h photo exhibition
JavaScript
1
star
24

boj-cli

๐Ÿ“‹ ๋ฐฑ์ค€ ๋ฌธ์ œ ํŒŒ์ผ ๊ด€๋ฆฌ Command Line Tool
Go
1
star
25

OneBorderBox

๐Ÿ“ One Side Bordered Rectangle View for SwiftUI ๐Ÿ“
Swift
1
star
26

one-man-ping-pong

pygame ์„ ํ™œ์šฉํ•œ 1์ธ ํ•‘ํ๊ฒŒ์ž„
Python
1
star
27

boj-solving

๋ฐฑ์ค€ ๋ฌธํ’€
C++
1
star
28

mt-ppt-generator

MT์—์„œ ์“ธ๋งŒํ•œ ๊ฒŒ์ž„ PPT ์ƒ์„ฑ script
Python
1
star
29

LottiePlayer

๐ŸญEasiest Way to Represent Lottie Animation in SwiftUI
Swift
1
star