Code Monkey home page Code Monkey logo

textureswiftsupport's Introduction

TextureSwiftSupport - Gains up your productivity

This is a library to gain Texture(AsyncDisplayKit) more power in Swift.

  • Readable Layout DSL
  • Composable components

And you might need to use TextureBridging to integrate with AutoLayout world in your applications.

Requirements

Swiift 5.3+

The cases of usage in Production

Layout DSL

Using resultBuilders, ASLayoutSpec can be more simply and readable it's like SwiftUI's decralations.

🕺🏻 You want to use this in AutoLayout?

Before

override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec {

  ASStackLayoutSpec(
    direction: .vertical,
    spacing: 0,
    justifyContent: .start,
    alignItems: .start,
    children: [
      self.textNode1,
      self.textNode2,
      self.textNode3,
    ]
  )
  
}

After

override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec {

  LayoutSpec {
    VStackLayout {
      self.textNode1
      self.textNode2
      self.textNode3
    }
  }
  
}

Wrapping with LayoutSpec enables us to write DSL inside this block.

More complicated example

LayoutSpec {
  if flag {
    VStackLayout {
      HStackLayout(justifyContent: .center) {
        iconNode
          .padding(.top, 24)
          .padding(.bottom, 16)
      }
      .background(gradientNode)
    }
  } else {
    gradientNode
  }
}

⚠️ Please take care of the differences between this DSL and SwiftUI.
This DSL just describes the node's layout. You should avoid to create a new node inside layout.
Since layoutSpecThatFits would be called multiple times.

Layouts

  • Basic Layouts

    • VStackLayout
    • HStackLayout
    • ZStackLayout
    • WrapperLayout
    • AbsoluteLayout
    • CenterLayout
    • RelativeLayout
    • InsetLayout
    • OverlayLayout
    • BackgroundLayout
    • AspectRatioLayout
    • SpacerLayout
  • Advanced Layouts

    • VGridLayout
    • AnyLayout
    • Switch

Modifiers

  • WIP

Composable components

TextureSwiftSupport provides us a lot of components that help to create a new component with compositioning from small components.

Technically, composing increases a number of view or layer in run-time. It might reduce the performance a bit.
But most of the cases, that won't be matters.

  • MaskingNode
  • BackgroundNode
  • OverlayNode
  • PaddingNode
  • WrapperCellNode
  • WrapperNode
  • ShapeLayerNode
  • ShapeRenderingNode
  • InteractiveNode
  • AnyDisplayNode
  • GradientNode

Author

Muukii [email protected]

textureswiftsupport's People

Contributors

aryasurya21 avatar ccomsi avatar johnestropia avatar muukii avatar ntnmrndn avatar shima11 avatar strangeliu avatar takumatt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

textureswiftsupport's Issues

.background color modifier

It would be nice to have a .background(Color.red) operator on a view, that sets the .backgroundColor of the ASDisplayNode. Is there a technical reason this isn't already in the library? If not, could that operator be added?

Support background color in layout

is it a way to support a background color method for changing color in layout, just like swiftui does?

List {
    Section(header: Text("First Section")) {
         Text("First Cell")
     }
     Section(header: Text("Second Section")) {
          Text("First Cell")
     }
}
.background(Color.yellow)

Support SPM

supporting Swift Package Manager in 2020 is must have

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.