Skip to content

Commit c924735

Browse files
Merge pull request #50 from raccoongang/develop
Develop to main. Release v1.2.1
2 parents 01a4a19 + 62bac08 commit c924735

File tree

5 files changed

+97
-62
lines changed

5 files changed

+97
-62
lines changed

Core/Core/View/Base/FlexibleKeyboardInputView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public struct FlexibleKeyboardInputView: View {
8888
}.frame(maxWidth: .infinity, maxHeight: commentSize + 16)
8989
.background(
9090
CoreAssets.commentCellBackground.swiftUIColor
91+
.ignoresSafeArea()
9192
)
9293
.overlay(
9394
GeometryReader { proxy in

Core/Core/View/Base/PickerMenu.swift

Lines changed: 90 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -42,68 +42,103 @@ public struct PickerMenu: View {
4242
self.items = items
4343
self.titleText = titleText
4444
self.router = router
45-
if let selectedItem {
46-
self._selectedItem = State(initialValue: selectedItem)
47-
}
45+
self._selectedItem = State(initialValue: selectedItem ?? items.first ?? PickerItem(key: "", value: ""))
4846
self.selected = selected
4947
}
50-
48+
49+
private var filteredItems: [PickerItem] {
50+
if search.isEmpty {
51+
return items
52+
} else {
53+
return items.filter { $0.value.localizedCaseInsensitiveContains(search) }
54+
}
55+
}
56+
57+
private var isSingleSelection: Bool {
58+
return filteredItems.count == 1
59+
}
60+
61+
private var isItemSelected: Bool {
62+
return filteredItems.contains(selectedItem)
63+
}
64+
65+
private var acceptButtonDisabled: Bool {
66+
return !isItemSelected && !isSingleSelection
67+
}
68+
5169
public var body: some View {
5270
VStack {
5371
ZStack(alignment: .bottom) {
54-
Color.black.opacity(0.4)
55-
.onTapGesture(perform: {
56-
router.dismiss(animated: true)
57-
})
72+
Color.black.opacity(0.4)
73+
.ignoresSafeArea()
74+
.onTapGesture {
75+
router.dismiss(animated: true)
76+
}
77+
VStack {
78+
Spacer()
5879
VStack {
59-
VStack {
60-
Text(titleText)
61-
.foregroundColor(CoreAssets.textPrimary.swiftUIColor)
62-
TextField(CoreLocalization.Picker.search, text: $search)
63-
.padding(.all, 8)
64-
.background(
65-
CoreAssets.textInputStroke.swiftUIColor
66-
.cornerRadius(6))
67-
Picker("", selection: $selectedItem) {
68-
let filteredItems = items
69-
.filter({ $0.value.contains(search) })
70-
ForEach(filteredItems.count != 0 ? filteredItems : items,
71-
id: \.self) {
72-
Text($0.value)
73-
.foregroundColor(CoreAssets.textPrimary.swiftUIColor)
74-
}
75-
}.pickerStyle(.wheel)
76-
77-
}.frame(minWidth: 0, maxWidth: idiom == .pad ? ipadPickerWidth : .infinity)
78-
.padding()
79-
.background(
80-
CoreAssets.textInputBackground.swiftUIColor
81-
.cornerRadius(16)
82-
).padding(.horizontal, 16)
83-
84-
Button(action: {
85-
if items
86-
.filter({ $0.value.contains(search) }).count == 1 {
87-
selectedItem = items
88-
.filter({ $0.value.contains(search) })[0]
80+
Text(titleText)
81+
.foregroundColor(CoreAssets.textPrimary.swiftUIColor)
82+
TextField(CoreLocalization.Picker.search, text: $search)
83+
.padding(.all, 8)
84+
.background(CoreAssets.textInputStroke.swiftUIColor.cornerRadius(6))
85+
Picker("", selection: $selectedItem) {
86+
ForEach(filteredItems, id: \.self) { item in
87+
Text(item.value)
88+
.foregroundColor(CoreAssets.textPrimary.swiftUIColor)
8989
}
90-
selected(selectedItem)
91-
router.dismiss(animated: true)
92-
}, label: {
93-
Text(CoreLocalization.Picker.accept)
94-
.foregroundColor(CoreAssets.textPrimary.swiftUIColor)
95-
.frame(minWidth: 0, maxWidth: idiom == .pad ? ipadPickerWidth : .infinity)
96-
.padding()
97-
.background(
98-
CoreAssets.textInputBackground.swiftUIColor
99-
.cornerRadius(16)
100-
).padding(.horizontal, 16)
101-
})
102-
.padding(.bottom, 50)
103-
104-
}.transition(.move(edge: .bottom))
90+
}
91+
.pickerStyle(.wheel)
92+
}
93+
.frame(minWidth: 0, maxWidth: idiom == .pad ? ipadPickerWidth : .infinity)
94+
.padding()
95+
.background(CoreAssets.textInputBackground.swiftUIColor.cornerRadius(16))
96+
.padding(.horizontal, 16)
97+
.onChange(of: search, perform: { _ in
98+
if let first = filteredItems.first {
99+
self.selectedItem = first
100+
}
101+
})
102+
103+
Button(action: {
104+
selected(selectedItem)
105+
router.dismiss(animated: true)
106+
}) {
107+
Text(CoreLocalization.Picker.accept)
108+
.foregroundColor(CoreAssets.textPrimary.swiftUIColor)
109+
.frame(minWidth: 0, maxWidth: idiom == .pad ? ipadPickerWidth : .infinity)
110+
.padding()
111+
.background(CoreAssets.textInputBackground.swiftUIColor.cornerRadius(16))
112+
.padding(.horizontal, 16)
113+
}
114+
.padding(.bottom, 4)
115+
.disabled(acceptButtonDisabled)
116+
}
117+
.avoidKeyboard(dismissKeyboardByTap: true)
118+
.transition(.move(edge: .bottom))
105119
}
106-
}.transition(.opacity)
107-
.ignoresSafeArea()
120+
}
121+
.transition(.opacity)
122+
123+
}
124+
125+
}
126+
127+
#if DEBUG
128+
struct PickerMenu_Previews: PreviewProvider {
129+
static var previews: some View {
130+
131+
let items = [
132+
PickerItem(key: "Uk", value: "Ukraine"),
133+
PickerItem(key: "Us", value: "United States of America"),
134+
PickerItem(key: "En", value: "England")
135+
]
136+
137+
return PickerMenu(items: items,
138+
titleText: "Select country",
139+
router: BaseRouterMock(),
140+
selectedItem: items.first,
141+
selected: {_ in})
108142
}
109143
}
144+
#endif

Discussion/Discussion/Presentation/Comments/Responses/ResponsesView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public struct ResponsesView: View {
195195
}
196196
}
197197
}
198-
}
198+
}.edgesIgnoringSafeArea(.bottom)
199199
.background(
200200
CoreAssets.background.swiftUIColor
201201
.ignoresSafeArea()

Discussion/Discussion/Presentation/Comments/Thread/ThreadView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public struct ThreadView: View {
232232
}
233233
}
234234
}
235-
}
235+
}.edgesIgnoringSafeArea(.bottom)
236236
.background(
237237
CoreAssets.background.swiftUIColor
238238
.ignoresSafeArea()

OpenEdX.xcodeproj/project.pbxproj

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@
227227
07D5DA2E28D075AA00752FD9 /* Frameworks */,
228228
07D5DA2F28D075AA00752FD9 /* Resources */,
229229
0770DE1528D07845006D8A5D /* Embed Frameworks */,
230-
02F175442A4E3B320019CD70 /* ShellScript */,
230+
02F175442A4E3B320019CD70 /* FirebaseCrashlytics */,
231231
);
232232
buildRules = (
233233
);
@@ -288,24 +288,23 @@
288288
/* End PBXResourcesBuildPhase section */
289289

290290
/* Begin PBXShellScriptBuildPhase section */
291-
02F175442A4E3B320019CD70 /* ShellScript */ = {
291+
02F175442A4E3B320019CD70 /* FirebaseCrashlytics */ = {
292292
isa = PBXShellScriptBuildPhase;
293293
buildActionMask = 8;
294294
files = (
295295
);
296296
inputFileListPaths = (
297297
);
298298
inputPaths = (
299-
"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}",
300-
"$(SRCROOT)/$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)",
301299
);
300+
name = FirebaseCrashlytics;
302301
outputFileListPaths = (
303302
);
304303
outputPaths = (
305304
);
306305
runOnlyForDeploymentPostprocessing = 1;
307306
shellPath = /bin/sh;
308-
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\n\"${BUILD_DIR%/Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run\"\n";
307+
shellScript = "case $CONFIGURATION in\n \"DebugDev\" | \"ReleaseDev\" )\n googleAppID=$(grep -A 4 'case .debugDev, .releaseDev:' ${PROJECT_DIR}/${TARGET_NAME}/Environment.swift | grep 'googleAppID:' | awk -F'\"' '{print $2}')\n ;;\n \"DebugStage\" | \"ReleaseStage\" )\n googleAppID=$(grep -A 4 'case .debugStage, .releaseStage:' ${PROJECT_DIR}/${TARGET_NAME}/Environment.swift | grep 'googleAppID:' | awk -F'\"' '{print $2}')\n ;;\n \"DebugProd\" | \"RelesaseProd\" )\n googleAppID=$(grep -A 4 'case .debugProd, .releaseProd:' ${PROJECT_DIR}/${TARGET_NAME}/Environment.swift | grep 'googleAppID:' | awk -F'\"' '{print $2}')\n ;;\n *)\n echo \"Unknown configuration\"\n ;;\nesac\n\nif [ -z \"$googleAppID\" ]\nthen\n echo \"GoogleAppID is empty. The FirebaseCrashlytics script will be skipped.\"\nelse\n \"${PODS_ROOT}/FirebaseCrashlytics/run\" --app-id \"$googleAppID\" -p ios ${DWARF_DSYM_FOLDER_PATH}\nfi\n";
309308
};
310309
0770DE2328D08647006D8A5D /* SwiftLint */ = {
311310
isa = PBXShellScriptBuildPhase;

0 commit comments

Comments
 (0)