Skip to content

Instantly share code, notes, and snippets.

final class ParallaxContentView: UIView {
  
  lazy var collectionView = UICollectionView(
    frame: .zero,
    collectionViewLayout: ParallaxFlowLayout()
  ).then {
    $0.contentInsetAdjustmentBehavior = .never
@audrl1010
audrl1010 / gist:dd41f7d5910f3e4ead747ea73c5f6a6e
Last active May 15, 2024 07:09
SwiftUI LazyStack 처럼, UIKit 용도의 Lazy Display Stack ScrollView 구현

LazyDisplayStackScrollView

What?

  • ScrollView에 StackView를 감싸서, 많은 양의 subviews들을 처음에 추가할 때 rendering 과부하가 걸리게 됩니다. scrolling시 화면에 보이는 영역의 subviews만 render할 수 있다면 굉장히 퍼포먼스가 좋을 것입니다. SwiftUI에서는 이러한 문제점을 인식했는 지 LazyStack이라는 것을 제공합니다. 하지만 UIKit에서는 그러한 것을 제공하지 않습니다. 이 라이브러리는 해당 이슈를 해결하기 위해 만들어졌습니다.

Description

  • on-demand subviews render를 지원합니다.
  • Note) subview(LazyDisplayView)를 추가할 때 estimatedHeight(추측 높이)값을 대략적으로 정확히 설정해주지 않으면, LazyDisplayStackScrollView가 좋은 성능을 내기 힘듭니다.

// MARK: - Merge extension Array where Element: Equatable {

func merge(target: [Element]) -> [Element] {
    let result = target.filter { item -> Bool in
        return self.contains(where: { item == $0}) == false
    }
    return self + result
}

}

// MARK: - Merge extension Array where Element: Equatable {

func merge(target: [Element]) -> [Element] {
    let result = target.filter { item -> Bool in
        return self.contains(where: { item == $0}) == false
    }
    return self + result
}

}

import RIBs
import RxSwift
import RxRelay
import ReactorKit

protocol FAQsRouting: ViewableRouting {
  func routeToFAQ(_ faq: FAQ)
  func detachFAQ()
}
@audrl1010
audrl1010 / RxCoordinator.md
Created April 6, 2019 15:09
RxCoordinator 분석
// completion handler for transitions
typealias PresentationHandler = () -> Void

// completion handler for transitions, which also provides the context
// information about the transition.
typealias ContextPresentationHandler = (
	PresentationHandlerContext
) -> Void
@audrl1010
audrl1010 / SwiftyFont.md
Last active March 27, 2019 10:09
SwiftyFont

Usage

class MessageCell: UICollectionViewCell {
  enum Font {
    static let titleLabel = 14.systemFont.semibold
    static let dateLabel = 14.systemFont.regular
    static let bodyLabel = 16.systemFont.light
  }
  let titleLabel = UILabel().then {
    $0.numberOfLines = 1
@audrl1010
audrl1010 / readme.md
Last active March 28, 2019 05:38
UITextField + Validator

Usage

class SignUpViewController: BaseViewController {
  let nicknameTextField = FormTextField(
    title: "닉네임",
    placeholder: "닉네임을 입력해주세요",
    rules: [.range(min: 1, max: 5, errorMessage: "잘못 입력")]
  )
  let emailTextField = FormTextField(
    title: "이메일",
@audrl1010
audrl1010 / gist:1cc2b45d697d288b81009e99273ac1c2
Last active February 21, 2019 08:32
approach auth in Next.js
const Secret = ({ loggedUser }) => (
  <div>
    <Content>
      Hi <strong>{ loggedUser.email }</string>. This is a secure page!
    </Content>
  </div>
);
@audrl1010
audrl1010 / signIn+signOff.md
Created February 21, 2019 08:27
JWT Auth Approach in Next.js

Sign In

import defaultPage from "../../hocs/defaultPage"
import { show } from "../../utils/lock";

class SignIn extends React.Component {
  componentDidMount() {
    show()
  }