-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ :: [#38] Add Signup 기능구현 / 코드 발송, 인증 기능추가
- Loading branch information
Showing
5 changed files
with
180 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// TimeManager.swift | ||
// Expo-iOS | ||
// | ||
// Created by 서지완 on 11/4/24. | ||
// Copyright © 2024 SchoolofCompany. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import Combine | ||
|
||
class TimerManager: ObservableObject { | ||
@Published var remainingTime = 180 | ||
@Published var timerActive = false | ||
private var timer: Timer? | ||
|
||
func startTimer() { | ||
// 타이머가 활성화되어 있을 경우, 초기화 및 재시작 | ||
if timerActive { | ||
resetTimer() | ||
} | ||
|
||
timerActive = true | ||
remainingTime = 180 | ||
|
||
timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { timer in | ||
if self.remainingTime > 0 { | ||
self.remainingTime -= 1 | ||
} else { | ||
timer.invalidate() | ||
self.timerActive = false | ||
} | ||
} | ||
} | ||
|
||
func resetTimer() { | ||
timer?.invalidate() | ||
timer = nil | ||
timerActive = false | ||
remainingTime = 180 | ||
} | ||
|
||
func timeFormatted(_ totalSeconds: Int) -> String { | ||
let minutes = totalSeconds / 60 | ||
let seconds = totalSeconds % 60 | ||
return String(format: "%02d:%02d", minutes, seconds) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
Projects/Domain/Sources/Request/Auth/Request/VeritfyCode/CodeVeritfyRequest.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// CodeVeritfyRequest.swift | ||
// Domain | ||
// | ||
// Created by 서지완 on 11/4/24. | ||
// Copyright © 2024 SchoolofCompany. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct CodeVeritfyRequest: Codable { | ||
var phoneNumber: String | ||
var code: String | ||
|
||
public init(phoneNumber: String, code: String) { | ||
self.phoneNumber = phoneNumber | ||
self.code = code | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters