wantedly / ios_night

Let's talk about iOS development -- iOS Night 📱🌙 You might apply to this meetup from
https://www.wantedly.com/companies/wantedly/projects
18 stars 0 forks source link

2019/12/17 19:30~20:30 #79

Closed ngtk closed 4 years ago

ngtk commented 4 years ago

⚠️ This repository is public. / 公開リポジトリです。

Why

Where

Pearl Jam (Subject to change)

5F, MG Shirokanedai Building (Wantedly, Inc. Tokyo HQ)

Who

You are working for Wantedly? Sure, you can join anytime. If not, you need to contact us first. Or, you can "want to visit" the meetup, which you can find in www.wantedly.com/companies/wantedly/projects.

What

You write topics like below contents and we talk about these on the meetup. Every participant needs to write one topic at least.

Also, you can find new topics from the newsletters:

How

         ・・・

参加者は開催までに話したいことを少なくとも1トピックをコメントしましょう。 ネタ被りを避けるために、まずはタイトルだけでコメントすることを推奨します。 より多くの学びを得るためにどんな内容でもアウトプットを歓迎します!😊

cc/ @wantedly/ios

Edit this template

Previous issue

sorakoro commented 4 years ago

SwiftUI Preview について

前回の続き

ngtk commented 4 years ago

Building Bottom sheet in SwiftUI

https://swiftwithmajid.com/2019/12/11/building-bottom-sheet-in-swiftui/

bottom-sheet

Usecase

struct ContentView: View {
    @State private var bottomSheetShown = false

    var body: some View {
        GeometryReader { geometry in
            Color.green
            BottomSheetView(
                isOpen: self.$bottomSheetShown,
                maxHeight: geometry.size.height * 0.7
            ) {
                Color.blue
            }
        }.edgesIgnoringSafeArea(.all)
    }
}

Implementation

@GestureState private var translation: CGFloat = 0

var body: some View {
    GeometryReader { geometry in
        VStack(spacing: 0) {
            self.indicator.padding()
            self.content
        }
        .frame(width: geometry.size.width, height: self.maxHeight, alignment: .top)
        .background(Color(.secondarySystemBackground))
        .cornerRadius(Constants.radius)
        .frame(height: geometry.size.height, alignment: .bottom)
        .offset(y: max(self.offset + self.translation, 0))
        .animation(.interactiveSpring())
        .gesture(
            DragGesture().updating(self.$translation) { value, state, _ in
                state = value.translation.height // インタラクティブに位置を更新
            }.onEnded { value in
                let snapDistance = self.maxHeight * Constants.snapRatio
                guard abs(value.translation.height) > snapDistance else {  // 移動距離が一定を超えていたらスナップする
                    return
                }
                self.isOpen = value.translation.height < 0  // 閉じるか開くかどちらかにスナップする
            }
        )
    }
}

code: https://gist.github.com/mecid/78eab34d05498d6c60ae0f162bfd81ee

ngtk commented 4 years ago

The Advanced Guide to UserDefaults in Swift

https://www.vadimbulavin.com/advanced-guide-to-userdefaults-in-swift/

var storage = Storage()

storage.isFirstLaunch = true
print(storage.isFirstLaunch) // true
jiro commented 4 years ago

SwiftUIに適したアプリケーション設計

https://medium.com/eureka-engineering/thought-about-arch-for-swiftui-1b0496d8094

状態管理のためのライブラリ https://github.com/muukii/Verge

hiranodept commented 4 years ago

Measure launch performance with UI tests

UITestでアプリの起動時間を測る。 Xcode11で新しく使えるようになった、measure(metrics:options:block:) メソッドを使う。

func testLaunchPerformance() {
        if #available(iOS 13.0, *) {
            measure(metrics: [XCTOSSignpostMetric.applicationLaunch]) {
                XCUIApplication().launch()
            }
        }
    }

実行するとテストを5回行う。 baselineを設定することで起動が遅くなった時に検知できる?

スクリーンショット 2019-12-17 19 01 20

ref: WWDC 2019 Session 417 Improving Battery Life and Performance ref: Testing App Launch Time