abceed
辞書ボトムシート
作り方
© 2022 Globee Inc. All rights reserved.
株式会社Globee
© 2022 Globee Inc. All rights reserved.
自己紹介
鈴木 俊裕
iOSエンジニア歴 8年+
6月からEMを兼務しています
34歳で5歳の娘がいます
最近トランペットを始めました
F1とか好きです
twitter: @toshi0383
会社のメンバーページ
© 2022 Globee Inc. All rights reserved.
© 2022 Globee Inc. All rights reserved.
背景と仕様
Sheetっぽいハーフモーダル
テキスト選択の検知
複数要素からのイベントハンドリング
目次
© 2022 Globee Inc. All rights reserved.
背景と仕様
© 2022 Globee Inc. All rights reserved.
abceedの辞書機能
自社コンテンツ
自社コンテンツ
© 2022 Globee Inc. All rights reserved.
© 2022 Globee Inc. All rights reserved.
課題
開発チームのボトムアップな意見
「画面全体を覆わない形でサッと意味を確認できる」
「辞書を開いたまま元の画面を触れる」
Android Chromeの標準の辞書の挙動がイメージに近い。
© 2022 Globee Inc. All rights reserved.
© 2022 Globee Inc. All rights reserved.
デザイン
© 2022 Globee Inc. All rights reserved.
© 2022 Globee Inc. All rights reserved.
デザイン
© 2022 Globee Inc. All rights reserved.
© 2022 Globee Inc. All rights reserved.
どう実装を進めたか
© 2022 Globee Inc. All rights reserved.
Sheetっぽいハーフモーダル
© 2022 Globee Inc. All rights reserved.
「Sheetっぽいハーフモーダル」とは
要件
© 2022 Globee Inc. All rights reserved.
© 2022 Globee Inc. All rights reserved.
「Sheetっぽいハーフモーダル」実現方法
要件
選択肢
© 2022 Globee Inc. All rights reserved.
© 2022 Globee Inc. All rights reserved.
“Sheet” like PanModal
© 2022 Globee Inc. All rights reserved.
© 2022 Globee Inc. All rights reserved.
プルリクの中身を見てみましょう
意訳: アルファ背景部分ドラッグできる既存仕様おかしくない?
© 2022 Globee Inc. All rights reserved.
© 2022 Globee Inc. All rights reserved.
プルリクの中身を見てみましょう
意訳: そのままだと後ろのビュー触れなかったからcontainerViewは触れないようにしたよ。けどそのままだと手前のビューが触れないのでこの行が必要だよ。
© 2022 Globee Inc. All rights reserved.
© 2022 Globee Inc. All rights reserved.
HitTestView
UIViewでOK
© 2022 Globee Inc. All rights reserved.
© 2022 Globee Inc. All rights reserved.
HitTestView
> 手前のビューが触れないのでこの行が必要だよ。
触れる後ろのビューから手前のビューにタッチを委譲する
© 2022 Globee Inc. All rights reserved.
© 2022 Globee Inc. All rights reserved.
テキスト選択の検知
© 2022 Globee Inc. All rights reserved.
テキスト選択の検知
© 2022 Globee Inc. All rights reserved.
© 2022 Globee Inc. All rights reserved.
テキスト選択を検知するコード
© 2022 Globee Inc. All rights reserved.
© 2022 Globee Inc. All rights reserved.
複数要素からのイベントハンドリング
© 2022 Globee Inc. All rights reserved.
複数要素ある画面の対応
単語の選択がWebView->TextViewに切り替わった場合
イベント順は当然ながら特に保証されない
この場合、ボトムシートは閉じないで単語だけ切り替えたい
© 2022 Globee Inc. All rights reserved.
© 2022 Globee Inc. All rights reserved.
WebView->TextViewに選択が変わったとき
こういう処理だと..
if let word = 現在選択されている単語を取得する() {
// シート開く or 更新する
} else {
// シート閉じる
}
一回閉じてしまう
debounceでごまかせる
閉じてしまう
ごまかせない
イベントの順番
© 2022 Globee Inc. All rights reserved.
© 2022 Globee Inc. All rights reserved.
ユーザーがまだ辞書使ってそうだったら閉じない
flatMapLatest + delay
© 2022 Globee Inc. All rights reserved.
© 2022 Globee Inc. All rights reserved.
辞書ボトムシート完成
© 2022 Globee Inc. All rights reserved.
© 2022 Globee Inc. All rights reserved.
利用者の声
© 2022 Globee Inc. All rights reserved.
© 2022 Globee Inc. All rights reserved.
まとめ
© 2022 Globee Inc. All rights reserved.
© 2022 Globee Inc. All rights reserved.
© 2022 Globee Inc. All rights reserved.
Globeeについて
28
社 名: | 株式会社 Globee |
本 社: | 東京都港区東麻布一丁目7番3号 |
代表者: | 幾嶋 研三郎 |
設 立: | 2014年6月12日 |
社員数: | 36名(派遣・業務委託含む) |
資本金: | 32,476,000円(資本準備金含む) |
エンジニア積極採用中!
© 2022 Globee Inc. All rights reserved.
© 2022 Globee Inc. All rights reserved.