Skip to content

Commit

Permalink
refactor: add SummaryWidgetHalfView
Browse files Browse the repository at this point in the history
  • Loading branch information
mmmmmob committed Jun 5, 2024
1 parent 936a222 commit c242eda
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 36 deletions.
4 changes: 4 additions & 0 deletions Lotto Journal.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
4AADFB5C2C03816F00AE57E6 /* OTPView in Frameworks */ = {isa = PBXBuildFile; productRef = 4AADFB5B2C03816F00AE57E6 /* OTPView */; };
4AADFB5F2C0392C100AE57E6 /* OTPView in Frameworks */ = {isa = PBXBuildFile; productRef = 4AADFB5E2C0392C100AE57E6 /* OTPView */; };
4ABEDA8B2C0EBB4E00D4174B /* IntExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ABEDA8A2C0EBB4E00D4174B /* IntExtension.swift */; };
4ABEDA8F2C101B4300D4174B /* SummaryWidgetHalfView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ABEDA8E2C101B4300D4174B /* SummaryWidgetHalfView.swift */; };
4ABEF1922BFC42D300904D3E /* CheckResultViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ABEF1912BFC42D300904D3E /* CheckResultViewModel.swift */; };
4ABEF1962BFC6F5500904D3E /* PrizeHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ABEF1952BFC6F5500904D3E /* PrizeHeaderView.swift */; };
4ABEF1982BFC715E00904D3E /* PrizeNumberView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ABEF1972BFC715E00904D3E /* PrizeNumberView.swift */; };
Expand Down Expand Up @@ -62,6 +63,7 @@
4A8C440C2BFAFA75000461B9 /* DateExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateExtension.swift; sourceTree = "<group>"; };
4A8C441D2BFB675B000461B9 /* Result.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Result.swift; sourceTree = "<group>"; };
4ABEDA8A2C0EBB4E00D4174B /* IntExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntExtension.swift; sourceTree = "<group>"; };
4ABEDA8E2C101B4300D4174B /* SummaryWidgetHalfView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SummaryWidgetHalfView.swift; sourceTree = "<group>"; };
4ABEF1912BFC42D300904D3E /* CheckResultViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckResultViewModel.swift; sourceTree = "<group>"; };
4ABEF1952BFC6F5500904D3E /* PrizeHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrizeHeaderView.swift; sourceTree = "<group>"; };
4ABEF1972BFC715E00904D3E /* PrizeNumberView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrizeNumberView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -135,6 +137,7 @@
4AD9DD4C2C04A59E00EE7866 /* Summary */ = {
isa = PBXGroup;
children = (
4ABEDA8E2C101B4300D4174B /* SummaryWidgetHalfView.swift */,
);
name = Summary;
sourceTree = "<group>";
Expand Down Expand Up @@ -312,6 +315,7 @@
4ABEF1962BFC6F5500904D3E /* PrizeHeaderView.swift in Sources */,
4A74D1392C02170C00A5C211 /* Lottery.swift in Sources */,
4ABEF1982BFC715E00904D3E /* PrizeNumberView.swift in Sources */,
4ABEDA8F2C101B4300D4174B /* SummaryWidgetHalfView.swift in Sources */,
4AF0975F2BF9DA21003A813B /* MyLotteryView.swift in Sources */,
4AFEAC382BFF795100BA40AD /* QuickActionType.swift in Sources */,
4ABEDA8B2C0EBB4E00D4174B /* IntExtension.swift in Sources */,
Expand Down
38 changes: 2 additions & 36 deletions Lotto Journal/Views/SummaryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,43 +91,9 @@ struct SummaryView: View {
.padding(40)
}
HStack {
RoundedRectangle(cornerRadius: 10)
.fill(Color.accentColor.opacity(0.7))
.frame(maxWidth: .infinity, maxHeight: 150)
.overlay {
VStack(alignment: .trailing) {
Text("💸 Total Spending")
.font(.system(.caption, design: .default, weight: .regular))
.foregroundStyle(.primary)
Text("฿\(totalSpending.delimiter)")
.font(.system(.largeTitle, design: .rounded, weight: .bold))
.foregroundStyle(.white)
.lineLimit(1)
.minimumScaleFactor(0.5)
}
.frame(maxWidth: .infinity, alignment: .trailing)
.foregroundStyle(.white)
.padding(.horizontal)
}
SummaryWidgetHalfView(numberToShow: totalSpending, headerText: "💸 Total Spending")
.padding(.leading)
RoundedRectangle(cornerRadius: 10)
.fill(Color.accentColor.opacity(0.7))
.frame(maxWidth: .infinity, maxHeight: 150)
.overlay {
VStack(alignment: .trailing) {
Text("🏆 Total Prize Won")
.font(.system(.caption, design: .default, weight: .regular))
.foregroundStyle(.primary)
Text("฿\(totalPrizeWon.delimiter)")
.font(.system(.largeTitle, design: .rounded, weight: .bold))
.foregroundStyle(.white)
.lineLimit(1)
.minimumScaleFactor(0.5)
}
.frame(maxWidth: .infinity, alignment: .trailing)
.foregroundStyle(.white)
.padding(.horizontal)
}
SummaryWidgetHalfView(numberToShow: totalPrizeWon, headerText: "🏆 Total Prize Won")
.padding(.trailing)
}
Spacer()
Expand Down
39 changes: 39 additions & 0 deletions Lotto Journal/Views/SummaryWidgetHalfView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// SummaryWidgetHalfView.swift
// Lotto Journal
//
// Created by Theppitak M. on 05.06.2024.
//

import SwiftUI

struct SummaryWidgetHalfView: View {

var numberToShow: Int
var headerText: String

var body: some View {
RoundedRectangle(cornerRadius: 10)
.fill(Color.accentColor.opacity(0.7))
.frame(maxWidth: .infinity, maxHeight: 150)
.overlay {
VStack(alignment: .trailing) {
Text(headerText)
.font(.system(.caption, design: .default, weight: .regular))
.foregroundStyle(.primary)
Text("฿\(numberToShow.delimiter)")
.font(.system(.largeTitle, design: .rounded, weight: .bold))
.foregroundStyle(.white)
.lineLimit(1)
.minimumScaleFactor(0.5)
}
.frame(maxWidth: .infinity, alignment: .trailing)
.foregroundStyle(.white)
.padding(.horizontal)
}
}
}

#Preview {
SummaryWidgetHalfView(numberToShow: 30000, headerText: "💸 Total Spending")
}

0 comments on commit c242eda

Please sign in to comment.