Closed ngtk closed 4 years ago
前回の続き
https://swiftwithmajid.com/2019/12/11/building-bottom-sheet-in-swiftui/
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)
}
}
@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
https://www.vadimbulavin.com/advanced-guide-to-userdefaults-in-swift/
var storage = Storage()
storage.isFirstLaunch = true
print(storage.isFirstLaunch) // true
https://medium.com/eureka-engineering/thought-about-arch-for-swiftui-1b0496d8094
状態管理のためのライブラリ https://github.com/muukii/Verge
UITestでアプリの起動時間を測る。
Xcode11で新しく使えるようになった、measure(metrics:options:block:)
メソッドを使う。
func testLaunchPerformance() {
if #available(iOS 13.0, *) {
measure(metrics: [XCTOSSignpostMetric.applicationLaunch]) {
XCUIApplication().launch()
}
}
}
実行するとテストを5回行う。
baseline
を設定することで起動が遅くなった時に検知できる?
ref: WWDC 2019 Session 417 Improving Battery Life and Performance ref: Testing App Launch Time
⚠️ 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