-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#118 ホスト作成、更新画面の作成 #184
#118 ホスト作成、更新画面の作成 #184
Conversation
…to 118_create_update_host
…to 118_create_update_host
packages/firebase_common/lib/src/firestore_repositories/host_location.dart
Show resolved
Hide resolved
// Hostの作成 | ||
final imageUrl = await _uploadImage(imageFile); | ||
await _hostService.create( | ||
workerId: workerId, | ||
displayName: displayName, | ||
introduction: introduction, | ||
hostTypes: hostTypes, | ||
urls: urls, | ||
imageUrl: imageUrl, | ||
); | ||
|
||
// Locationの作成 | ||
await _locationService.create( | ||
hostId: workerId, | ||
address: address, | ||
geo: geo, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
後で対応メモ:画面全体の OverlayLoading を有効にして使うと良さそう
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
こちらは何か修正しますか?
ついでに直せる内容でしたら修正します!
await _hostService.create( | ||
workerId: workerId, | ||
displayName: displayName, | ||
introduction: introduction, | ||
hostTypes: hostTypes, | ||
urls: urls, | ||
imageUrl: imageUrl, | ||
); | ||
|
||
// Locationの作成 | ||
await _locationService.create( | ||
hostId: workerId, | ||
address: address, | ||
geo: geo, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この 2 つは実際にはセットでコールするものなので、Controller が順に呼ぶというよりは、host と hostLocation を一緒に更新するサービスクラスのメソッドを定義するべきかも?と思いました!(そのサービスクラスの名前は HostService
で良いと思います。今回する必要はないですが、本来はバッチ書き込みしても良いような内容なので)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修正しました!
await _hostService.update( | ||
hostId: hostId, | ||
displayName: displayName, | ||
introduction: introduction, | ||
hostTypes: hostTypes, | ||
urls: urls, | ||
imageUrl: imageUrl, | ||
); | ||
|
||
// Locationの更新 | ||
final locations = | ||
await _locationService.fetchHostLocationsFromHost(hostId: hostId); | ||
if (locations != null && locations.isNotEmpty) { | ||
await _locationService.update( | ||
hostLocationId: locations.first.hostLocationId, | ||
address: address, | ||
geo: geo, | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここもまるっとひとつのモデル(サービス)クラスのメソッドで書くべきかもなと思いました!
また前にちょっと話しましたが、host vs. hostLocation は常に 1 対 1 の前提で良いと思っていました!(ホストに「あなたが登録している hostLocation 一覧」みたいな画面を作るつもりもないです)分かりづらくてすみません🙏
それならそもそも hostLocation の id は hostId と一致でも良さそうですね...!
※ 上記は対応したかったら & できそうだったらでいいです!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修正しました!
final formKey = GlobalKey<FormState>(); | ||
|
||
/// 選択中のホストタイプ | ||
final List<HostType> _selectedHosyTypes = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
タイポ:_selectedHostTypes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ご指摘ありがとうございます。
修正しました!
static LatLng convertGeoToLatLng(Geo? geo) { | ||
var latitude = 0.0; | ||
|
||
var longitude = 0.0; | ||
|
||
if (geo != null) { | ||
latitude = geo.geopoint.latitude; | ||
longitude = geo.geopoint.longitude; | ||
} | ||
|
||
return LatLng(latitude, longitude); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static メソッドにしている必要はなさそう?単に private メソッドで OK?
[確認]
null
が入ってくると LatLng(0, 0)
が返されるのは意図通りですか?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
すみません、開発過程で別のクラスに置いていたので、修正が漏れていました。
nullが入ってくることがないので、修正しました!
|
||
/// 入力が必須か任意かを表すバッジ | ||
/// [isRequired] の値によって、必須か任意の文字を選択して返す。 | ||
class _OptionalBadge extends StatelessWidget { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
host_form と job_form とで Duplicated なので共通のものとして lib/widgets/ にでも置いてほしいです!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
新しくOpstionalBadge
クラスを定義しました!
/// [TextField]をGridで表示するウィジェット | ||
/// GridViewの場合は、aspect比を指定する必要があり、 | ||
/// [TextField]のような可変長aspect比が必要なウィジェットでは使用できないため作成 | ||
class _VariableHeightGrid extends StatelessWidget { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なるほど... 意外と難しいんですね
@@ -51,4 +51,40 @@ class HostService { | |||
/// 指定した [Host] を取得する。 | |||
Future<ReadHost?> fetchHost({required String hostId}) => | |||
_hostRepository.fetchHost(hostId: hostId); | |||
|
|||
/// [Host] の情報を作成する。 | |||
Future<void> create({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
上で書いたとおりですが、Controller で色々書いているのをモデルに移動してほしいです。現状モデルは単に Repository のメソッドを呼ぶだけの感じになっています。Controller が肥大化するのではなく、モデルにロジックを書きます。Controller は ユーザー操作をモデルに伝えるもの、UI を操作するものであることを意識してみてください!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修正しました!
…to 118_create_update_host
Issue
close #118
説明
ホスト作成、更新画面を作成しました。
仕様
デバッグ用開発ページ
UI
■バリデーション実行
■作成
■更新
その他
その他に言及したいことがあれば書いてください。
チェックリスト