Skip to content

Commit 7a228c8

Browse files
committed
Modify convert button
1 parent 0474657 commit 7a228c8

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

OpenCCman.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
BE3AECB82B2EF6F700820673 /* ProAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE3AECB32B2EF6F700820673 /* ProAlertView.swift */; };
4747
BE3F71DF2B2F4F47001496EA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE3F71DE2B2F4F47001496EA /* AppDelegate.swift */; };
4848
BE3F71E22B2F4F8F001496EA /* IQKeyboardManagerSwift in Frameworks */ = {isa = PBXBuildFile; platformFilter = ios; productRef = BE3F71E12B2F4F8F001496EA /* IQKeyboardManagerSwift */; };
49+
BE3F71E42B2F5377001496EA /* UIApplicationExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE3F71E32B2F5377001496EA /* UIApplicationExtensions.swift */; };
4950
BE727E2C2B2DE16400C63DB2 /* HomeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE727E2B2B2DE16400C63DB2 /* HomeViewModel.swift */; };
5051
BE727E2E2B2DF60400C63DB2 /* SegmentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE727E2D2B2DF60400C63DB2 /* SegmentView.swift */; };
5152
BE727E322B2DF65D00C63DB2 /* VisualEffects in Frameworks */ = {isa = PBXBuildFile; productRef = BE727E312B2DF65D00C63DB2 /* VisualEffects */; };
@@ -91,6 +92,7 @@
9192
BE3AECB22B2EF6F700820673 /* MyAppView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MyAppView.swift; sourceTree = "<group>"; };
9293
BE3AECB32B2EF6F700820673 /* ProAlertView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProAlertView.swift; sourceTree = "<group>"; };
9394
BE3F71DE2B2F4F47001496EA /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
95+
BE3F71E32B2F5377001496EA /* UIApplicationExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIApplicationExtensions.swift; sourceTree = "<group>"; };
9496
BE727E2B2B2DE16400C63DB2 /* HomeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewModel.swift; sourceTree = "<group>"; };
9597
BE727E2D2B2DF60400C63DB2 /* SegmentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SegmentView.swift; sourceTree = "<group>"; };
9698
BE727E332B2DF85E00C63DB2 /* UserDefaultsKeys.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserDefaultsKeys.swift; sourceTree = "<group>"; };
@@ -139,6 +141,7 @@
139141
BE2C6D492B2D7ED000FC4112 /* BundleExtensions.swift */,
140142
BE2C6D4A2B2D7ED000FC4112 /* IntExtensions.swift */,
141143
BE2C6D4C2B2D7ED000FC4112 /* DateExtensions.swift */,
144+
BE3F71E32B2F5377001496EA /* UIApplicationExtensions.swift */,
142145
);
143146
path = extensions;
144147
sourceTree = "<group>";
@@ -368,6 +371,7 @@
368371
BE2C6D642B2D80D100FC4112 /* ButtonStyles.swift in Sources */,
369372
BE3AECAB2B2EF46A00820673 /* TestNumbersPerDayManager.swift in Sources */,
370373
BE3AECA42B2EF3B200820673 /* BackButton.swift in Sources */,
374+
BE3F71E42B2F5377001496EA /* UIApplicationExtensions.swift in Sources */,
371375
BE2C6D552B2D7ED000FC4112 /* ColorExtensions.swift in Sources */,
372376
BE3AECB42B2EF6F700820673 /* AlertView.swift in Sources */,
373377
BE2C6D592B2D7ED000FC4112 /* BundleExtensions.swift in Sources */,

OpenCCman/Scene/HomeScene.swift

+14-8
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,20 @@ struct HomeScene: View {
9191
)
9292

9393
VStack(alignment: .leading, spacing: Constant.padding) {
94-
Text("Source").font(.headline)
94+
HStack {
95+
Text("Source").font(.headline)
96+
Spacer()
97+
Button(action: {
98+
#if os(iOS)
99+
UIApplication.shared.endEditing()
100+
#endif
101+
viewModel.translate()
102+
}, label: {
103+
Text("Convert")
104+
.font(.headline)
105+
})
106+
.softButtonStyle(RoundedRectangle(cornerRadius: 20), padding: 10, mainColor: Color.accentColor, textColor: Color.Neumorphic.main)
107+
}
95108
TextEditor(text: $viewModel.inputText)
96109
.clearTextEdtorStyle()
97110
.frame(maxWidth: .infinity, minHeight: 200, maxHeight: 300)
@@ -118,13 +131,6 @@ struct HomeScene: View {
118131
})
119132
.softButtonStyle(Circle(), padding: 6)
120133
Spacer()
121-
Button(action: {
122-
viewModel.translate()
123-
}, label: {
124-
Text("Convert")
125-
.font(.headline)
126-
})
127-
.softButtonStyle(RoundedRectangle(cornerRadius: 20), padding: 10, mainColor: Color.accentColor, textColor: Color.Neumorphic.main)
128134
}
129135
Text(viewModel.resultText)
130136
.textSelectable()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#if os(iOS)
2+
import UIKit
3+
4+
extension UIApplication {
5+
func endEditing() {
6+
sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
7+
}
8+
}
9+
#endif

0 commit comments

Comments
 (0)