Skip to content

Commit

Permalink
[2.0.6] 설문조사 팝업 완성 (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
wonniiii authored Aug 1, 2024
1 parent d207cbb commit 1456253
Show file tree
Hide file tree
Showing 12 changed files with 281 additions and 65 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "popup.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Group 212.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group 213.png",
"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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
137 changes: 72 additions & 65 deletions KuringApp/KuringApp/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,74 +15,81 @@ import SettingsFeatures
import ComposableArchitecture

struct ContentView: View {
@State private var selection: TabBarItem = .notice

enum TabBarItem: Hashable {
case notice
case archive
case campusMap
case settings
}

init() {
UITabBar.appearance().barTintColor = UIColor.init(Color.Kuring.bg)
}

var body: some View {
TabView(selection: $selection) {
NoticeApp(
store: Store(
initialState: NoticeAppFeature.State(
noticeList: NoticeListFeature.State()
),
reducer: { NoticeAppFeature()._printChanges() }
)
)
.tag(TabBarItem.notice)
.tabItem {
Image(selection == .notice ? .listFill : .list)

Text("공지사항")
}

BookmarkApp(
store: Store(
initialState: BookmarkAppFeature.State(
bookmarkList: BookmarkListFeature.State()
),
reducer: { BookmarkAppFeature() }
)
)
.tag(TabBarItem.archive)
.tabItem {
Image(selection == .archive ? .archiveFill : .archive)

Text("공지보관함")
}

CampusApp()
.tag(TabBarItem.campusMap)
.tabItem {
Image(selection == .campusMap ? .mapPinFill : .mapPin)

Text("캠퍼스맵")
}
@State private var selection: TabBarItem = .notice

enum TabBarItem: Hashable {
case notice
case archive
case campusMap
case settings
}

init() {
UITabBar.appearance().barTintColor = UIColor.init(Color.Kuring.bg)
}

var body: some View {
ZStack {
TabView(selection: $selection) {
NoticeApp(
store: Store(
initialState: NoticeAppFeature.State(
noticeList: NoticeListFeature.State()
),
reducer: { NoticeAppFeature()._printChanges() }
)
)
.tag(TabBarItem.notice)
.tabItem {
Image(selection == .notice ? .listFill : .list)

Text("공지사항")
}

BookmarkApp(
store: Store(
initialState: BookmarkAppFeature.State(
bookmarkList: BookmarkListFeature.State()
),
reducer: { BookmarkAppFeature() }
)
)
.tag(TabBarItem.archive)
.tabItem {
Image(selection == .archive ? .archiveFill : .archive)

Text("공지보관함")
}

CampusApp()
.tag(TabBarItem.campusMap)
.tabItem {
Image(selection == .campusMap ? .mapPinFill : .mapPin)

SettingsApp(
store: Store(
initialState: SettingsAppFeature.State(),
reducer: { SettingsAppFeature() }
)
)
.tag(TabBarItem.settings)
.tabItem {
Image(selection == .settings ? .moreHorizontalFill : .moreHorizontal)

Text("더보기")
}
Text("캠퍼스맵")
}

SettingsApp(
store: Store(
initialState: SettingsAppFeature.State(),
reducer: { SettingsAppFeature() }
)
)
.tag(TabBarItem.settings)
.tabItem {
Image(selection == .settings ? .moreHorizontalFill : .moreHorizontal)

Text("더보기")
}
.tint(Color.Kuring.gray600)
}
.tint(Color.Kuring.gray600)

/// 팝업 추가
if PopupView.checkShowPopup() {
PopupView()
}
}
}
}

#Preview {
Expand Down
139 changes: 139 additions & 0 deletions KuringApp/KuringApp/PopupView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
//
// SwiftUIView.swift
//
//
// Created by 최효원 on 8/1/24.
//

import SwiftUI
import ColorSet

struct PopupView: View {
@State private var isPresented: Bool = true

var body: some View {
if isPresented {
ZStack {
Color.black.opacity(0.4)
.edgesIgnoringSafeArea(.all)

VStack(spacing: 0) {
headerView
footerView
}
.background(Color.gray)
.cornerRadius(15)
.frame(width: 280, height: 290)
}
}
}

private var headerView: some View {
ZStack {
Rectangle()
.fill(Color.Kuring.primary)

VStack(spacing: 0) {
HStack {
Spacer()
closeButton
}
.padding(16)

Image("Popup.icon")
.padding(.bottom, 15)

Text("쿠링 이용자분들의\n소중한 의견을 구합니다!")
.font(.system(size: 18, weight: .bold))
.foregroundStyle(Color.Kuring.gray100)
.multilineTextAlignment(.center)
.lineSpacing(3)
.padding(.bottom, 12)

infoView
.padding(.bottom, 12)
}
}
.frame(height: 230)
}

private var closeButton: some View {
Button(action: {
isPresented = false
}) {
Image(systemName: "xmark")
.foregroundColor(Color.Kuring.gray100)
}
}

private var infoView: some View {
HStack(alignment: .center, spacing: 19) {
infoItem(title: "참여대상", description: "건국대학교\n재학생 및 휴학생")
infoItem(title: "설문조사 기간", description: "2024.07.30 ~\n 2024.08.05")
infoItem(title: "설문조사 경품", description: "아이스 아메리카노\n기프티콘")
}
.padding(12)
.frame(height: 56)
.font(.system(size: 8))
.background(
RoundedRectangle(cornerRadius: 6)
.fill(Color.Kuring.primarySelected)
.opacity(0.3)
)
.overlay(
RoundedRectangle(cornerRadius: 6)
.stroke(Color.Kuring.primarySelected, lineWidth: 0.5)
.opacity(0.6)
)
}

private func infoItem(title: String, description: String) -> some View {
VStack(spacing: 2) {
Text(title).fontWeight(.semibold)
Text(description)
.multilineTextAlignment(.center)
}
.foregroundStyle(Color.Kuring.body)
}

private var footerView: some View {
ZStack {
Rectangle()
.fill(Color.Kuring.bg)

Button(action: {
UserDefaults.standard.set(true, forKey: "hasParticipated")
isPresented = false
if let url = URL(string: "https://tally.so/r/npVg48") {
UIApplication.shared.open(url)
}
}) {
Text("설문 참여하러 가기")
.foregroundStyle(Color.Kuring.primary)
.font(.system(size: 16, weight: .semibold))
}
}
.frame(height: 60)
}


/// 팝업 표시 여부 판단 함수
static func checkShowPopup() -> Bool {
let calendar = Calendar.current
let currentDate = Date()

/// 2024년 8월 6일 정각까지
let targetDateComponents = DateComponents(year: 2024, month: 8, day: 6, hour: 0, minute: 0, second: 0)
let targetDate = calendar.date(from: targetDateComponents) ?? Date()

/// UserDefaults에서 참여 여부 확인
let hasParticipated = UserDefaults.standard.bool(forKey: "hasParticipated")

/// 현재 날짜가 목표 날짜 이전이고, 참여하지 않은 경우에만 팝업을 표시
return currentDate < targetDate && !hasParticipated
}
}

#Preview {
PopupView()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "popup.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Group 212.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group 213.png",
"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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions package-kuring/Sources/UIKit/PopupUI/PopupView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// SwiftUIView.swift
//
//
// Created by 최효원 on 8/1/24.
//

import SwiftUI

struct SwiftUIView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}

#Preview {
SwiftUIView()
}

0 comments on commit 1456253

Please sign in to comment.