Skip to content

Commit 6440137

Browse files
Minor cleanup
1 parent 5056ce4 commit 6440137

File tree

12 files changed

+49
-289
lines changed

12 files changed

+49
-289
lines changed

Sources/PassioNutritionUIModule/NutritionUIModule/NutritionUI/Extensions/Array2+Extension.swift renamed to Sources/PassioNutritionUIModule/NutritionUIModule/NutritionUI/Extensions/Array+Extension.swift

File renamed without changes.

Sources/PassioNutritionUIModule/NutritionUIModule/NutritionUI/Extensions/Data+Extension.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,4 @@ extension Data {
1616
let insecure = computed.map { String(format: "%02hhx", $0) }.joined()
1717
return insecure
1818
}
19-
2019
}

Sources/PassioNutritionUIModule/NutritionUIModule/NutritionUI/Extensions/Date+Extension.swift

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -83,51 +83,38 @@ extension Date {
8383
dateComponents.day = day
8484
return calendar.date(from: dateComponents) ?? Date()
8585
}
86-
}
87-
extension Date {
88-
/**
89-
Finds the first day of the week the subject date falls into.
90-
91-
- Parameter calendar: The calendar to use. Defaults to the user's current calendar.
92-
93-
- Returns: The `Date` of the first day of the week into which the subject date falls.
94-
95-
`startOfWeek()` respects the user's locale settings, i.e. will automatically use Sunday/Monday/etc. as first
96-
weekday based on the user's region and locale settings.
97-
*/
98-
func startOfWeek(using calendar: Calendar = .current) -> Date {
99-
var components = calendar.dateComponents([.weekday, .year, .month, .weekOfYear], from: self)
100-
components.weekday = calendar.firstWeekday
101-
return calendar.date(from: components) ?? self
102-
}
103-
86+
87+
func startOfWeek(using calendar: Calendar = .current) -> Date {
88+
var components = calendar.dateComponents([.weekday, .year, .month, .weekOfYear],
89+
from: self)
90+
components.weekday = calendar.firstWeekday
91+
return calendar.date(from: components) ?? self
92+
}
93+
10494
func startAndEndOfWeek(calendar: Calendar = .current) -> (start: Date, end: Date)? {
10595
// Get the start of the week
106-
guard let startOfWeek = calendar.date(from: calendar.dateComponents([.yearForWeekOfYear, .weekOfYear], from: self)) else {
96+
guard let startOfWeek = calendar.date(from: calendar.dateComponents([.yearForWeekOfYear, .weekOfYear],
97+
from: self)) else {
10798
return nil
10899
}
109-
110100
// Get the end of the week
111101
guard let endOfWeek = calendar.date(byAdding: DateComponents(day: 6), to: startOfWeek) else {
112102
return nil
113103
}
114-
115104
return (startOfWeek, endOfWeek)
116105
}
117-
118-
106+
119107
func startAndEndOfMonth(calendar: Calendar = .current) -> (start: Date, end: Date)? {
120108
// Get the start of the month
121-
guard let startOfMonth = calendar.date(from: calendar.dateComponents([.year, .month], from: self)) else {
109+
guard let startOfMonth = calendar.date(from: calendar.dateComponents([.year, .month],
110+
from: self)) else {
122111
return nil
123112
}
124-
125113
// Get the end of the month
126-
guard let endOfMonth = calendar.date(byAdding: DateComponents(month: 1, day: -1), to: startOfMonth) else {
114+
guard let endOfMonth = calendar.date(byAdding: DateComponents(month: 1, day: -1),
115+
to: startOfMonth) else {
127116
return nil
128117
}
129-
130118
return (startOfMonth, endOfMonth)
131119
}
132-
133120
}

Sources/PassioNutritionUIModule/NutritionUIModule/NutritionUI/Extensions/Double+Extension.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ extension Optional where Wrapped == Double {
1919
return (wself * multiplier).rounded()/multiplier
2020
}
2121
}
22+
2223
extension Double {
2324

2425
func roundDigits(afterDecimal: Int) -> Double {
@@ -37,6 +38,7 @@ extension Double {
3738
}
3839

3940
extension Double {
41+
4042
var clean: String {
4143
return self.truncatingRemainder(dividingBy: 1) == 0 ? String(format: "%.0f", self) : String(self)
4244
}
@@ -60,7 +62,8 @@ extension Double {
6062
}
6163
}
6264

63-
extension CGFloat{
65+
extension CGFloat {
66+
6467
func normalize(toMultipleOf multiple: Int) -> CGFloat {
6568
guard multiple > 0 else {
6669
fatalError("Multiple should be greater than 0")

Sources/PassioNutritionUIModule/NutritionUIModule/NutritionUI/Extensions/String+Extension.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ extension String {
103103
}
104104

105105
}
106+
106107
extension UILabel {
107108
func setAttributedTextWithFont(for substring: String, font: UIFont) {
108109
guard let labelText = self.text else {

Sources/PassioNutritionUIModule/NutritionUIModule/NutritionUI/Helper/CustomTappableButton.swift

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// DateFormatString.swift
3+
// BaseApp
4+
//
5+
// Created by Nikunj Prajapati on 24/02/22.
6+
// Copyright © 2022 Passio Inc. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
// MARK: - DateFormat String
12+
enum DateFormatString {
13+
static let EEEE_MMM_dd_yyyy = "EEEE MMM dd yyyy"
14+
static let MMMM_yyyy = "MMMM - yyyy"
15+
static let yyyy_MM_dd = "yyyy/MM/dd"
16+
static let h_mm_a = "h:mm a"
17+
static let HH_mm = "HH.mm"
18+
static let HHmm = "HH:mm"
19+
static let MM_dd_yyyy_E = "MM/dd/yyyy | E"
20+
static let M_d_yyyy = "M-d-yyyy"
21+
static let M_d_yyyy2 = "M/d/yyyy"
22+
static let yyyyMMdd = "yyyyMMdd"
23+
static let EEEMMMddYYYYhmma = "EEE, MMM dd YYYY, h:mm a"
24+
}

Sources/PassioNutritionUIModule/NutritionUIModule/NutritionUI/Helper/String+Constants.swift

Lines changed: 0 additions & 93 deletions
This file was deleted.

0 commit comments

Comments
 (0)