Skip to content

Commit

Permalink
Merge pull request #105 from tukcomCD2024/SNOW-70-feat#86/generate-logic
Browse files Browse the repository at this point in the history
Feat#86/generate logic
  • Loading branch information
SeungEEE authored Jun 18, 2024
2 parents b86cbaa + 3e5579d commit 909e9dd
Show file tree
Hide file tree
Showing 26 changed files with 1,425 additions and 122 deletions.
469 changes: 468 additions & 1 deletion iOS/Memetory/Memetory.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
"version" : "1.7.5"
}
},
{
"identity" : "aws-sdk-ios-spm",
"kind" : "remoteSourceControl",
"location" : "https://github.com/aws-amplify/aws-sdk-ios-spm",
"state" : {
"revision" : "f7e79d076556210b1aec4289cc0028d7ac785959",
"version" : "2.36.3"
}
},
{
"identity" : "googlesignin-ios",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -50,17 +59,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/kakao/kakao-ios-sdk",
"state" : {
"revision" : "ab226a7a3625d64e73a52aa3800595dab810156b",
"version" : "2.22.1"
"revision" : "9f9b830dfd7ee66607c6fddcfeb1a6bc07e48714",
"version" : "2.22.2"
}
},
{
"identity" : "snapkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SnapKit/SnapKit.git",
"state" : {
"revision" : "e74fe2a978d1216c3602b129447c7301573cc2d8",
"version" : "5.7.0"
"revision" : "2842e6e84e82eb9a8dac0100ca90d9444b0307f4",
"version" : "5.7.1"
}
}
],
Expand Down
37 changes: 37 additions & 0 deletions iOS/Memetory/Memetory/AWS/Environment.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// Environment.swift
// Memetory
//
// Created by 이승진 on 2024/06/17.
//

import Foundation

struct Environment {
static func load() {
guard let envPath = Bundle.main.path(forResource: ".env", ofType: nil) else {
print(".env file not found")
return
}

// 경로 출력
print("Env file path: \(envPath)")

do {
let envContents = try String(contentsOfFile: envPath)
print("Env file contents:\n\(envContents)")
let envLines = envContents.split(separator: "\n")

for line in envLines {
let keyValue = line.split(separator: "=")
if keyValue.count == 2 {
let key = String(keyValue[0]).trimmingCharacters(in: .whitespaces)
let value = String(keyValue[1]).trimmingCharacters(in: .whitespaces)
setenv(key, value, 1)
}
}
} catch {
print("Failed to read .env file: \(error)")
}
}
}
18 changes: 18 additions & 0 deletions iOS/Memetory/Memetory/AWS/S3Configuration.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// S3Configuration.swift
// Memetory
//
// Created by 이승진 on 2024/05/12.
//

import Foundation

enum S3Configuration : String
{
// case IDENTITY_POOL_ID = "Your Identity Pool Id"
case BUCKET_NAME = "memetory"
// case CALLBACK_KEY = "Personality Message"
case CONTENT_TYPE_IMAGE = "image/jpg"
case CONTENT_TYPE_VIDEO = "video/mp4"
case CONTENT_TYPE_TXT = "text/plain"
}
88 changes: 88 additions & 0 deletions iOS/Memetory/Memetory/AWS/S3Manager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
//
// S3Manager.swift
// Memetory
//
// Created by 이승진 on 2024/06/17.
//

import UIKit
import AWSS3

class S3Manager {
static let shared = S3Manager()

let S3BucketName = "memetory"

private init() {

}

func uploadImage(image: UIImage, completion: @escaping (String?) -> Void) {
guard let imageData = image.jpegData(compressionQuality: 0.9) else {
print("imgae X")
completion(nil)
return
}
let transferUtility = AWSS3TransferUtility.default()

let expression = AWSS3TransferUtilityUploadExpression()
expression.setValue("AES256", forRequestHeader: "x-amz-server-side-encryption")
expression.progressBlock = { (task, progress) in
DispatchQueue.main.async {
print("[ Upload progress ]: \(progress.fractionCompleted)")
}
}

let currentDate = Date()
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyyMMddhhmmssSSS"
let fileName = dateFormatter.string(from: currentDate) + ".jpg"

transferUtility.uploadData(
imageData,
bucket: S3BucketName,
key: fileName,
contentType: "image/jpg",
expression: expression
) { (task, error) in
if let error = error {
print("Error uploading image: \(error.localizedDescription)")
completion(nil)
} else {
print("Image uploaded successfully!")
completion(fileName)
}
}
}


func uploadFile(data: Data, bucketName: String, key: String, completion: @escaping (Bool, Error?) -> Void) {
let expression = AWSS3TransferUtilityUploadExpression()
let transferUtility = AWSS3TransferUtility.default()

transferUtility.uploadData(data, bucket: bucketName, key: key, contentType: "text/plain", expression: expression) { task, error in
if let error = error {
print("Upload failed with error: \(error)")
completion(false, error)
} else {
print("Upload successful")
completion(true, nil)
}
}
}

func downloadFile(bucketName: String, key: String, completion: @escaping (Data?, Error?) -> Void) {
let expression = AWSS3TransferUtilityDownloadExpression()
let transferUtility = AWSS3TransferUtility.default()

transferUtility.downloadData(fromBucket: bucketName, key: key, expression: expression) { task, url, data, error in
if let error = error {
print("Download failed with error: \(error)")
completion(nil, error)
} else {
print("Download successful")
completion(data, nil)
}
}
}
}
46 changes: 39 additions & 7 deletions iOS/Memetory/Memetory/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,69 @@
//

import UIKit
import AWSS3
import KakaoSDKCommon
import AWSCore

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
sleep(3) // 런치스크린 3초 유지
KakaoSDK.initSDK(appKey: "15e306b70c4ce1164dca0a70a9d39c94")
let navigationBarAppearance = UINavigationBar.appearance()
navigationBarAppearance.tintColor = .black

// return true

// AWS S3
// let credentialProvider = AWSCognitoCredentialsProvider(regionType: .APNortheast2, identityPoolId: S3Configuration.IDENTITY_POOL_ID.rawValue)
// guard let configuration = AWSServiceConfiguration(region: .APNortheast2, credentialsProvider: credentialProvider) else {
// print("[ FAILED TO CONNECT AWS S3 ]")
// return false
// }
// AWSS3TransferUtility.register(with: configuration, forKey: S3Configuration.CALLBACK_KEY.rawValue)
// print("[ SUCCESS TO CONNECT AWS S3 ]")
// return true

print("Start loading environment")
// 환경 변수 로드
Environment.load()

// 환경 변수 자격 증명 읽기
guard let accessKey = ProcessInfo.processInfo.environment["AWS_ACCESS_KEY"],
let secretKey = ProcessInfo.processInfo.environment["AWS_SECRET_KEY"] else {
print("Missing AWS")
return false
}
print("엑세스키: \(accessKey)")
print("시크릿키: \(secretKey)")

let credentialsProvider = AWSStaticCredentialsProvider(accessKey: accessKey, secretKey: secretKey)
let configuration = AWSServiceConfiguration(region: .APNortheast2, credentialsProvider: credentialsProvider)
AWSServiceManager.default().defaultServiceConfiguration = configuration

print("[ SUCCESS TO CONNECT AWS S3 ]")
return true
}

// MARK: UISceneSession Lifecycle

func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}

func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}


}

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "LoadingImage.png",
"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" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "radio-button-line.png",
"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.
13 changes: 13 additions & 0 deletions iOS/Memetory/Memetory/View/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ class HomeViewController: UIViewController {
label.font = UIFont(name: "Pretendard-Bold", size: 25)
return label
}()

let monthLikeView: UIView = {
let view = UIView()
view.backgroundColor = .clear
return view
}()

let playButton: UIButton = {
let button = UIButton(type: .custom)
button.setImage(UIImage(systemName: "play.circle"), for: .normal)
button.tintColor = .white
return button
}()

override func viewDidLoad() {
super.viewDidLoad()
Expand Down
42 changes: 42 additions & 0 deletions iOS/Memetory/Memetory/View/Login/NickNameSetViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class NickNameSetViewController: UIViewController {
let tf = UITextField()
tf.textAlignment = .left
tf.borderStyle = .none
tf.textColor = .black
return tf
}()

Expand Down Expand Up @@ -138,3 +139,44 @@ class NickNameSetViewController: UIViewController {
}

}

extension NickNameSetViewController: UITextViewDelegate {
//화면 터치시 키보드 내림
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
self.view.endEditing(true)
}

// func textView(_ textView: UITextView, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
// let newText = (textView.text as NSString?)?.replacingCharacters(in: range, with: string) ?? ""
// let characterCount = newText.count
//
// if characterCount <= 50 {
// characterCountLabel.text = "\(characterCount)/50"
// return true
// } else {
// return false
// }
// }

func textViewDidBeginEditing(_ textView: UITextView) {
// 텍스트 필드가 편집을 시작할 때 호출되는 메서드
textView.layer.cornerRadius = 8.0 // 둥근 테두리 반지름 설정
textView.layer.borderWidth = 1.0 // 테두리 두께 설정
// textView.text = nil
// textField.layer.borderColor = WithYouAsset.mainColorDark.color.cgColor
}

// func textViewDidEndEditing(_ textView: UITextView) {
//// textField.layer.borderColor = WithYouAsset.subColor.color.cgColor
// if (lineTextView.text == "") {
// lineTextView.text = "대사를 입력해주세요!"
// lineTextView.textColor = .gray
// }
// }

func textViewShouldReturn(_ textView: UITextView) -> Bool {
// Process of closing the Keyboard when the line feed button is pressed.
textView.resignFirstResponder()
return true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// Member.swift
// Memetory
//
// Created by 이승진 on 2024/05/15.
//

import Foundation

struct Member : Codable {
var name : String
var imageUrl : String
}
Loading

0 comments on commit 909e9dd

Please sign in to comment.