Skip to content

Commit

Permalink
Merge pull request #64 from School-of-Company/62-ExpoEdit-Publishing
Browse files Browse the repository at this point in the history
🔀 :: [#62] 박람회 수정 퍼블리싱
  • Loading branch information
Xixn2 authored Nov 15, 2024
2 parents 689eb3e + 3be5400 commit c932061
Show file tree
Hide file tree
Showing 17 changed files with 588 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## 💡 개요
###

## 📃 작업내용

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "grayXButton.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "location.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "photoImage.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "photoget.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "plusBlue.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "warning.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
106 changes: 106 additions & 0 deletions Projects/App/Sources/DesignSystem/TextField/ExpoTextEditor.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
//
// ExpoTextEditor.swift
// Expo-iOS
//
// Created by 서지완 on 11/14/24.
// Copyright © 2024 SchoolofCompany. All rights reserved.
//

import SwiftUI

struct ExpoTextEditor: View {
@Binding var text: String
@FocusState private var isFocused: Bool
var title: String
var placeholder: String
var errorText: String
var isError: Bool
var onSubmit: () -> Void

private var borderColor: Color {
isError ? ExpoColor.error.swiftUIColor : ExpoColor.gray300.swiftUIColor
}

@State private var dynamicHeight: CGFloat = 50 // Default height for the first line

public init(
_ placeholder: String = "",
text: Binding<String>,
title: String = "",
errorText: String = "",
isError: Bool = false,
onSubmit: @escaping () -> Void = {}
) {
self._text = text
self.placeholder = placeholder
self.title = title
self.errorText = errorText
self.isError = isError
self.onSubmit = onSubmit
}

var body: some View {
VStack(alignment: .leading, spacing: 4) {
if !title.isEmpty {
Text(title)
.expoFont(.body2B)
.expoColor(ExpoColor.black)
}

ZStack(alignment: .topLeading) {
TextEditor(text: $text)
.padding(.horizontal, 16)
.padding(.top, 4)
.expoFont(.caption1R)
.frame(height: dynamicHeight) // Initial height is fixed at 50
.onChange(of: text) { newValue in
// Adjust height dynamically once the content grows
if newValue.count > 0 {
self.dynamicHeight = self.calculateHeight(for: newValue)
}
}
.onSubmit(onSubmit)
.focused($isFocused)
.overlay {
RoundedRectangle(cornerRadius: 8)
.strokeBorder(borderColor)
}
.cornerRadius(8)
.onTapGesture {
isFocused = true
}

if text.isEmpty {
Text(placeholder)
.expoFont(.caption1R)
.expoColor(ExpoColor.gray300)
.padding(.top, 14)
.padding(.leading, 20)
}
}

if isError {
Text(errorText)
.expoColor(ExpoColor.error)
.expoFont(.caption2R)
}
}
.padding(.horizontal, 16)
}

private func calculateHeight(for text: String) -> CGFloat {
let width = UIScreen.main.bounds.width - 40 // Adjust for padding
let font = UIFont.systemFont(ofSize: 17) // Set the font to match your text style
let attributes = [NSAttributedString.Key.font: font]

let boundingRect = NSString(string: text).boundingRect(
with: CGSize(width: width, height: .infinity),
options: .usesLineFragmentOrigin,
attributes: attributes,
context: nil
)

// Return height based on content, but no less than 50
return max(50, boundingRect.height + 20) // Ensure a minimum height of 50
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct ExpoTextField: View {
if isError {
return ExpoColor.error.swiftUIColor
} else {
return ExpoColor.gray100.swiftUIColor
return ExpoColor.gray300.swiftUIColor
}
}

Expand Down
42 changes: 42 additions & 0 deletions Projects/App/Sources/Extension/ImagePicker.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// ImagePicker.swift
// Expo-iOS
//
// Created by 서지완 on 11/14/24.
// Copyright © 2024 SchoolofCompany. All rights reserved.
//

import Foundation
import SwiftUI

struct ImagePicker: UIViewControllerRepresentable {
@Binding var selectedImage: UIImage?
@Environment(\.presentationMode) private var presentationMode

func makeUIViewController(context: UIViewControllerRepresentableContext<ImagePicker>) -> UIImagePickerController {
let picker = UIImagePickerController()
picker.delegate = context.coordinator
return picker
}

func updateUIViewController(_ uiViewController: UIImagePickerController, context: UIViewControllerRepresentableContext<ImagePicker>) {}

func makeCoordinator() -> Coordinator {
Coordinator(self)
}

class Coordinator: NSObject, UINavigationControllerDelegate, UIImagePickerControllerDelegate {
let parent: ImagePicker

init(_ parent: ImagePicker) {
self.parent = parent
}

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
if let image = info[.originalImage] as? UIImage {
parent.selectedImage = image
}
parent.presentationMode.wrappedValue.dismiss()
}
}
}
Loading

0 comments on commit c932061

Please sign in to comment.