Skip to content

Commit

Permalink
Merge pull request #184 from shilokuma-inc/feat/keyboardDismiss
Browse files Browse the repository at this point in the history
【FEAT】キーボード入力後に上部をタップで入力状態から抜けられるように
  • Loading branch information
mrs1669 authored May 19, 2024
2 parents d7aba51 + e18f083 commit 947bd2f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions NinjacordApp/SettingMessage/SendMessageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,21 @@ struct SendMessageView: View {
@State var inputEmbedTitle = ""

@State var isTapEnable: Bool = false
@State private var isEditing: Bool = false
private var viewModel = SendMessageViewModel()

var body: some View {
ZStack {
Color.discordGray
.ignoresSafeArea(edges: [.top])
.onTapGesture {
if self.isEditing {
UIApplication.shared.sendAction(
#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil
)
self.isEditing = false
}
}
VStack(spacing: .zero) {
VStack(spacing: 8.0) {
Spacer()
Expand All @@ -36,6 +45,9 @@ struct SendMessageView: View {
.onChange(of: inputURL, initial: true) { _ in
textFieldValidation()
}
.onTapGesture {
self.isEditing = true
}

if !inputURL.isEmpty {
Button(action: {
Expand All @@ -52,18 +64,27 @@ struct SendMessageView: View {
placeholder: "名前を入れてください",
text: $inputUsername
)
.onTapGesture {
self.isEditing = true
}

withIconTextFieldView(
icon: Image(systemName: "person.crop.square"),
placeholder: "プロフィール画像のURLを入れてください",
text: $inputAvatarURL
)
.onTapGesture {
self.isEditing = true
}

withIconTextFieldView(
icon: Image(systemName: "square.and.pencil"),
placeholder: "メッセージを入れてください",
text: $inputContext
)
.onTapGesture {
self.isEditing = true
}
}
.padding(.horizontal)

Expand All @@ -76,6 +97,9 @@ struct SendMessageView: View {
text: $inputEmbedTitle
)
.padding(.horizontal)
.onTapGesture {
self.isEditing = true
}

Spacer()
.frame(height: 48.0)
Expand Down

0 comments on commit 947bd2f

Please # to comment.