Skip to content

Commit

Permalink
👍 issue #3 CardViewでカードの基本スタイルを構造体定義し、今後使いまわせるようにした。PlanDo画面に`Car…
Browse files Browse the repository at this point in the history
…dView`を適用した
  • Loading branch information
tora-muscle committed Feb 14, 2023
1 parent da4f736 commit 06395b9
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 33 deletions.
4 changes: 4 additions & 0 deletions 1weekPDCA.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
5C4B8CF02994CE4800B6348E /* ColorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C4B8CEF2994CE4800B6348E /* ColorExtension.swift */; };
5C62FE7029922A640046A41F /* BottomBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C62FE6F29922A640046A41F /* BottomBar.swift */; };
5C62FE7229922EE70046A41F /* theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C62FE7129922EE70046A41F /* theme.swift */; };
5C68C427299B63C8005FE6E2 /* cardView_model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C68C426299B63C8005FE6E2 /* cardView_model.swift */; };
5CA6AC13298799D1004AE124 /* Main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CA6AC12298799D1004AE124 /* Main.swift */; };
5CA6AC15298799D1004AE124 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CA6AC14298799D1004AE124 /* ContentView.swift */; };
5CA6AC17298799D5004AE124 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5CA6AC16298799D5004AE124 /* Assets.xcassets */; };
Expand Down Expand Up @@ -51,6 +52,7 @@
5C4B8CEF2994CE4800B6348E /* ColorExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorExtension.swift; sourceTree = "<group>"; };
5C62FE6F29922A640046A41F /* BottomBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottomBar.swift; sourceTree = "<group>"; };
5C62FE7129922EE70046A41F /* theme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = theme.swift; sourceTree = "<group>"; };
5C68C426299B63C8005FE6E2 /* cardView_model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = cardView_model.swift; sourceTree = "<group>"; };
5CA6AC0F298799D1004AE124 /* 1weekPDCA.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = 1weekPDCA.app; sourceTree = BUILT_PRODUCTS_DIR; };
5CA6AC12298799D1004AE124 /* Main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Main.swift; sourceTree = "<group>"; };
5CA6AC14298799D1004AE124 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -123,6 +125,7 @@
isa = PBXGroup;
children = (
5C4B8CEC2994ADE100B6348E /* tabBar_model.swift */,
5C68C426299B63C8005FE6E2 /* cardView_model.swift */,
);
path = domain;
sourceTree = "<group>";
Expand Down Expand Up @@ -464,6 +467,7 @@
5CA6AC15298799D1004AE124 /* ContentView.swift in Sources */,
5C62FE7229922EE70046A41F /* theme.swift in Sources */,
5C24155B299A2DCE00259CEB /* PlanDo.swift in Sources */,
5C68C427299B63C8005FE6E2 /* cardView_model.swift in Sources */,
5C62FE7029922A640046A41F /* BottomBar.swift in Sources */,
5C4B8CED2994ADE100B6348E /* tabBar_model.swift in Sources */,
5CA6AC13298799D1004AE124 /* Main.swift in Sources */,
Expand Down
37 changes: 37 additions & 0 deletions 1weekPDCA/domain/cardView_model.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// cardView_model.swift
// 1weekPDCA
//
// Created by 齊藤虎太郎 on 2023/02/14.
//

import Foundation
import SwiftUI

struct CardView<Content: View>: View {
let content: Content

init(@ViewBuilder content: () -> Content) {
self.content = content()
}

var body: some View {
ZStack {
VStack(spacing: 20) {
Spacer().frame(height: 7)
content
}
.padding(Edge.Set.horizontal, 50)
.background(
GeometryReader { geometry in
Rectangle()
.fill(Color.cardColorGray)
.cornerRadius(25)
.padding(Edge.Set.horizontal, 25)
.frame(height: geometry.size.height + 20)
}
)
}
.frame(height: 120)
}
}
53 changes: 20 additions & 33 deletions 1weekPDCA/presentation/PlanDo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,48 +72,35 @@ struct CustomProgressBar: View {
struct WeekProgressBarCard: View {
let today = Date()
let calendar = Calendar.current

// let progress: Double

var body: some View {
let weekRange = getWeekRange()
let progress = 0.71 // 現時点ではモック化のために定数に設定
let progress = 0.71

ZStack {
VStack(spacing: 20) {
Spacer().frame(height: 7)
HStack {
let (_, _) = getWeekRange()
Text(formatWeekRangeText(weekRange))
.font(.system(size: 20))
.fontWeight(.bold)
.foregroundColor(Color.uiColorGray)
Spacer()
}

HStack {
Spacer()
CustomProgressBar(progress: progress)
.frame(height: 20)// 進捗ごとに色を変える実装にする予定

Spacer()
}
CardView {
HStack {
Text(formatWeekRangeText(weekRange))
.font(.system(size: 20))
.fontWeight(.bold)
.foregroundColor(Color.uiColorGray)

Spacer()
}

HStack {
Spacer()
CustomProgressBar(progress: progress)
.frame(height: 20)
Spacer()
}
.padding(Edge.Set.horizontal, 50)
.background(
GeometryReader { geometry in
Rectangle()
.fill(Color.cardColorGray)
.cornerRadius(25)
.padding(Edge.Set.horizontal, 25)
// 子 View の高さに応じて可変するようにした
.frame(height: geometry.size.height + 20)
}
)
}
.frame(height: 120) // WeekProgressBarCardの最小の高さ
.frame(height: 120)
}
}



struct PlanDoPage_Previews: PreviewProvider {
static var previews: some View {
ZStack {
Expand Down

0 comments on commit 06395b9

Please sign in to comment.