• Stars
    star
    127
  • Rank 282,790 (Top 6 %)
  • Language
    Swift
  • License
    Apache License 2.0
  • Created about 2 years ago
  • Updated 6 months ago

Reviews

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

Repository Details

๐ŸŒบ HypeUI is a implementation of Apple's SwiftUI DSL style based on UIKit

HypeUI

๐Ÿš€ HypeUI is a implementation of Apple's SwiftUI DSL style based on UIKit Want to enjoy SwiftUI syntax with UIKit? It's time to use HypeUI ๐Ÿ˜Š

Awesome Swift

Why to use HypeUI?
๐Ÿ“ฑ Support iOS 12+
โœจ HypeUI is compatible with UIKit based project using SwiftUI style syntax
๐Ÿ„โ€โ™‚๏ธ Reduce UI & Autolayout codes more than 30%
โ›ณ๏ธ Provide UI binding extension with RxSwift and RxCocoa
๐Ÿฆ„ Easy to use!
โœˆ๏ธ Improve readability and intuitiveness of complex layouts
๐Ÿคฉ Have a blast
โ›ท Customize reusable component, design system
โ„๏ธ Test with accessibility Identifier

Contents

Requirements

  • iOS 12.0+
  • XCode 13.0+
  • Swift 5.0+

Installation

Swift Package Manager

Swift Package Manager is a tool for managing the distribution of Swift code. Itโ€™s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

Xcode 13+ is required to build HypeUI using Swift Package Manager.

To integrate HypeUI into your Xcode project using Swift Package Manager, add it to the dependencies value of your Package.swift:

dependencies: [
    .package(url: "https://github.com/hyperconnect/HypeUI", .upToNextMajor(from: "0.3.0"))
]

CocoaPod

The preferred installation method is with CocoaPods. Add the following to your Podfile:

pod 'HypeUI'

Supported Features

Supported Features
HStack โœ…
VStack โœ…
ZStack โœ…
Button โœ…
Text โœ…
Image โœ…
ScrollView โœ…
Behavior โœ…
Spacer โœ…
LinearGradient โœ…
AlignmentView โœ…
ViewBuildable โœ…
View Modifier โœ…
Text Modifier โœ…
Stack Modifier โœ…
Image Modifier โœ…
ScrollView Modifier โœ…

View Modifier

name Description
setHContentHugging Sets the priority with which a view resists being made larger than its intrinsic size.
setVContentHugging Sets the priority with which a view resists being made larger than its intrinsic size.
setHContentCompressionResistance Sets the priority with which a view resists being made smaller than its intrinsic size.
setVContentCompressionResistance Sets the priority with which a view resists being made smaller than its intrinsic size.
makeRatio Modify the ratio of the size of the view.
cornerRadius Modify corner radius.
border Modify border style.
background Modifiy background color.
makeContentMode Modify content mode.
frame Positions this view within an invisible frame with the specified size.
padding Adds an equal padding amount to specific edges of this view.
allowsHitTesting Configures whether this view participates in hit test operations.
masksToBounds Setting sublayers are clipped to the layerโ€™s bounds.
accessibilityIdentifier Uses the string you specify to identify the view.
overlay Layers the views that you specify in front of this view.
background Layers the views that you specify behind this view.

Text Modifier

name Description
font Modify text font.
foregroundColor Modify foreground color.
textAligned Modify text alignment
lineLimit The maximum number of lines that text can occupy in a view.
lineBreakMode Modify line break mode.
adjustFontSize Modify adjustsfontsize to fit width
minimumScaleFactor Modify minimum scale factor.

Stack Modifier

name Description
distributed Modify stack's distribution layout.

Image Modifier

name Description
tintColor Modify tint color.

ScrollView Modifier

name Description
bounces Modify scroll view bounces.
isPagingEnabled Modify scroll view paging enabled.
isScrollEnabled Modify scroll view enabled.

Usage

HStack

HStack(alinement: .center, spacing: 4) {
    Image(Asset.icStar.image)
        .frame(width: 12, height: 12)
    Text()
        .foregroundColor(UIColor.black)
        .font(UIFont.systemFont(ofSize: 14, weight: .regular))
    Spacer()
}

VStack

VStack(spacing: 8) {
    Text()
        .foregroundColor(UIColor.black)
        .font(UIFont.systemFont(ofSize: 14, weight: .regular))
    Spacer()
}

ZStack

ZStack {
    HStack(alinement: .center, spacing: 4) {
        Image(Asset.icStar.image)
            .frame(width: 12, height: 12)
        Text()
            .foregroundColor(UIColor.black)
            .font(UIFont.systemFont(ofSize: 14, weight: .regular))
        Spacer()
    }
    VStack {
        Text()
            .foregroundColor(UIColor.black)
            .font(UIFont.systemFont(ofSize: 14, weight: .regular))
        Spacer()
    }
}

Button

Button(action: { // DO SOMETHING ex) reactor action, closure }) {
    HStack(alignment: .center, spacing: 5.0) {
        Image("cart")
            .padding(.leading, 10.0)
        Text("Add to Cart")
            .foregroundColor(.black)
            .padding(.all, 10.0)
    }
}
.background(Color.gray)
.cornerRadius(5)

Text

Text("โœจ")
    .foregroundColor(UIColor.black)
    .font(UIFont.systemFont(ofSize: 14, weight: .regular))
    .textAligned(.center)
    .background(.white)
    .cornerRadius(16)

Image

Image(Resource.Profile.placeholderImage)
    .frame(width: 48, height: 48)
    .cornerRadius(24)

ScrollView

// MARK: Example
ScrollView(.vertical, showsIndicators: false) {
    VStack(alignment: .fill) {
        Image(image: Asset.imgPopupPrivateCall.image)
            .makeRatio(0.46106)
        Spacer()
            .frame(height: 24)
        VStack {
            viewModel.messages.map { message in
                HStack(alignment: .top, spacing: 8) {
                    Text("โ€ข")
                        .font(UIFont.systemFont(ofSize: 14, weight: .regular))
                        .foregroundColor(.Palette.gray04)
                        .frame(width: 6)
                    Text(message)
                        .font(UIFont.systemFont(ofSize: 14, weight: .regular))
                        .foregroundColor(.Palette.gray04)
                        .lineLimit(2)
                        .lineBreakMode(.byCharWrapping)
                    Spacer()
                        .frame(width: 5)
                }
                .padding(.vertical, 8)
            }
        }
        Spacer()
            .frame(height: 16)
    }
}

@Behavior - It's seems like SwiftUI's @State using DynamicLinkable ๐Ÿ˜Ž

@Behavior var isLive: Bool = false
@Behavior var username: String? = nil
@Behavior var profileImageURL: URL? = nil

// MARK Example
final class SearchHostHistoryViewCell: UICollectionViewCell {
    @Behavior var isLive: Bool = false
    @Behavior var username: String? = nil
    @Behavior var profileImageURL: URL? = nil

    override init(frame: CGRect) {
        super.init(frame: frame)
        contentView.addSubviewWithFit(
            ZStack {
                VStack(alignment: .center, spacing: 8) {
                    Image(Resource.Profile.placeholderImage)
                        .linked($profileImageURL.flatMapLatest { $0?.getImage(failover: Resource.Profile.placeholderImage) ?? .just(Resource.Profile.placeholderImage) }, keyPath: \.image)
                        .makeContentMode(.scaleAspectFill)
                        .frame(width: 48, height: 48)
                        .cornerRadius(24)
                        .background(.Palette.gray05)
                    Text("")
                        .linked($username, keyPath: \.text)
                        .textAligned(.center)
                        .foregroundColor(.darkModeSupporting(.Palette.gray01, .Palette.dkGray01))
                        .font(UIFont.systemFont(ofSize: 10, weight: .regular))
                        .frame(height: 12)
                }.padding(UIEdgeInsets(top: 12, left: 0, bottom: 4, right: 0))
                VStack(alignment: .center) {
                    Spacer()
                    Text("LIVE")
                        .foregroundColor(.Palette.white)
                        .font(UIFont.systemFont(ofSize: 8, weight: .bold))
                        .padding(UIEdgeInsets(top: 2, left: 4, bottom: 2, right: 4))
                        .background(.Palette.red)
                        .cornerRadius(4)
                        .linked($isLive.not(), keyPath: \.isHidden)
                    Spacer()
                        .frame(height: 20)
                }
            }
        )
    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

Spacer

Spacer()
    .frame(width: 10)
Spacer()
    .frame(height: 20)

LinearGradient

ProfileView()
    .background(
        LinearGradient(
            gradient: Gradient(
                stops: [
                    Stop(color: UIColor.black, location: 1.0),
                    Stop(color: UIColor.black, location: 0.2),
                    Stop(color: UIColor.black, location: 0.0)
                ]),
            startPoint: .top,
            endPoint: .bottom
        )
    )

ViewBuildable - Customize UI, Make reusable component and Design System by confirming ViewBuildable protocol.

struct ProfileView: ViewBuildable {
    @Behavior var country: String
    @Behavior var name: String

    func build() -> UIView {
        VStack {
            HStack(alignment: .center, spacing: 12) {
                Text("")
                    .linked($country, keyPath: \.text)
                    .font(UIFont.systemFont(ofSize: 20, weight: .regular))
                    .accessibilityIdentifier("country")
                Text("")
                    .linked($name, keyPath: \.text)
                    .font(UIFont.systemFont(ofSize: 20, weight: .regular))
                    .accessibilityIdentifier("name")
            }
        }
    }
}

Main Contributors

[email protected] [email protected] [email protected] [email protected]

Dependencies

More Repositories

1

TC-ResNet

Code for Temporal Convolution for Real-time Keyword Spotting on Mobile Devices
Python
216
star
2

MMNet

Code for Towards Real-Time Automatic Portrait Matting on Mobile Devices
Python
177
star
3

LADE

This repository contains code for the paper "Disentangling Label Distribution for Long-tailed Visual Recognition", published at CVPR' 2021
Python
96
star
4

MarioNETte

MarioNETte: Few-shot Face Reenactment Preserving Identity of Unseen Targets
39
star
5

pseudo-dialog-prompting

This repository contains code for the paper "Meet Your Favorite Character: Open-domain Chatbot Mimicking Fictional Characters with only a Few Utterances", published at NAACL' 2022
Python
12
star
6

hyperconnect.github.io

ํ•˜์ดํผ์ปค๋„ฅํŠธ ๊ธฐ์ˆ ๋ธ”๋กœ๊ทธ์ž…๋‹ˆ๋‹ค
HTML
10
star
7

trusthresh

An official codebase for the paper, "Reliable Decision from Multiple Subtasks through Threshold Optimization: Content Moderation in the Wild", WSDM'23
Python
10
star
8

FasTEN

Python
9
star
9

g2r

Codebase for the EMNLP 2021 Paper "Distilling the Knowledge of Large-scale Generative Models into Retrieval Models for Efficient Open-domain Conversation".
Python
6
star
10

TiDAL

Python
5
star
11

sem-ent

An official codebase for the paper, "Measuring and Improving Semantic Diversity of Dialogue Generation", EMNLP 2022 Findings
Python
4
star
12

corge

An official codebase for the paper "Understanding and Improving the Exemplar-based Generation for Open-domain Conversation", which is presented at ACL 2022, 4th Workshop on NLP for ConvAI as an oral paper.
Python
3
star
13

Attentron

Attentron: Few-shot Text-to-Speech Exploiting Attention-based Variable Length Embedding
1
star
14

pypipeline-tutorial

Python
1
star