Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
1
1weather
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
1weather
Commits
a989dda1
Commit
a989dda1
authored
Oct 07, 2021
by
Dmitry Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
In proccess to migrate to Rainfall model
parent
a8f9810e
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
46 additions
and
9 deletions
+46
-9
1Weather/UI/View controllers/Settings/Cells/SettingsCellFactory.swift
+3
-3
1Weather/UI/View controllers/Settings/Cells/SettingsDetailsCellFactory.swift
+6
-0
1Weather/ViewModels/SettingsDetailsViewModel.swift
+8
-2
BlendMinutelySource/BlendMinutelySource/BlendMinutelySource.swift
+1
-1
OneWeatherCore/OneWeatherCore/Extensions/Dimension+Name.swift
+12
-1
OneWeatherCore/OneWeatherCore/HelperTypes.swift
+8
-0
OneWeatherCore/OneWeatherCore/ModelObjects/Minutely/MinutelyItem.swift
+2
-2
OneWeatherCore/OneWeatherCore/Settings/DefaultSettings/DefaultSettings.swift
+1
-0
OneWeatherCore/OneWeatherCore/Settings/DefaultSettings/DefaultSettingsImperial.swift
+1
-0
OneWeatherCore/OneWeatherCore/Settings/DefaultSettings/DefaultSettingsMetric.swift
+1
-0
OneWeatherCore/OneWeatherCore/Settings/Settings.swift
+3
-0
No files found.
1Weather/UI/View controllers/Settings/Cells/SettingsCellFactory.swift
View file @
a989dda1
...
...
@@ -98,7 +98,7 @@ class SettingsCellFactory: CellFactory {
}
array
.
append
(
contentsOf
:
[
SettingsDataSource
(
section
:
.
units
,
rows
:
[
.
temperature
,
.
wind
,
.
pressure
,
.
distance
]),
SettingsDataSource
(
section
:
.
units
,
rows
:
[
.
temperature
,
.
wind
,
.
pressure
,
.
distance
,
.
rainfall
]),
// SettingsDataSource(section: .language, rows: [.language]),
SettingsDataSource
(
section
:
.
other
,
rows
:
[
// .manageNotifications,
...
...
@@ -153,8 +153,8 @@ class SettingsCellFactory: CellFactory {
name
=
viewModel
.
settings
.
distanceType
.
name
symbol
=
viewModel
.
settings
.
distanceType
.
symbol
case
.
rainfall
:
name
=
"mm"
symbol
=
"mm/h"
name
=
viewModel
.
settings
.
rainfallType
.
name
symbol
=
viewModel
.
settings
.
rainfallType
.
symbol
default
:
break
}
...
...
1Weather/UI/View controllers/Settings/Cells/SettingsDetailsCellFactory.swift
View file @
a989dda1
...
...
@@ -32,6 +32,8 @@ class SettingsDetailsCellFactory: CellFactory {
return
viewModel
.
pressures
.
count
case
.
distance
:
return
viewModel
.
distances
.
count
case
.
rainfall
:
return
viewModel
.
rainFalls
.
count
case
.
language
:
return
viewModel
.
languages
.
count
default
:
...
...
@@ -77,6 +79,10 @@ class SettingsDetailsCellFactory: CellFactory {
cell
.
configure
(
item
:
viewModel
.
distances
[
indexPath
.
row
]
.
name
,
isSelected
:
indexPath
.
row
==
viewModel
.
selectedDistanceIndex
,
roundedConrers
:
mask
)
case
.
rainfall
:
cell
.
configure
(
item
:
viewModel
.
rainFalls
[
indexPath
.
row
]
.
name
,
isSelected
:
indexPath
.
row
==
viewModel
.
selectedRainfallIndex
,
roundedConrers
:
mask
)
case
.
language
:
cell
.
configure
(
item
:
Localize
.
displayNameForLanguage
(
viewModel
.
languages
[
indexPath
.
row
]),
isSelected
:
indexPath
.
row
==
viewModel
.
selectedLanguageIndex
,
...
...
1Weather/ViewModels/SettingsDetailsViewModel.swift
View file @
a989dda1
...
...
@@ -26,6 +26,9 @@ class SettingsDetailsViewModel: ViewModelProtocol {
public
var
distances
:[
UnitLength
]
{
return
[
.
miles
,
.
kilometers
]
}
public
var
rainFalls
:
[
UnitRainfall
]
{
return
[
.
millimetersPerHour
,
.
inchesPerHour
]
}
public
var
languages
:[
String
]
{
return
Localize
.
availableLanguages
()
}
...
...
@@ -37,12 +40,15 @@ class SettingsDetailsViewModel: ViewModelProtocol {
public
var
selectedWindIndex
:
Int
{
return
winds
.
firstIndex
{
$0
==
Settings
.
shared
.
windSpeedType
}
??
-
1
}
public
var
selectedPressureIndex
:
Int
{
public
var
selectedPressureIndex
:
Int
{
return
pressures
.
firstIndex
{
$0
==
Settings
.
shared
.
pressureType
}
??
-
1
}
public
var
selectedDistanceIndex
:
Int
{
public
var
selectedDistanceIndex
:
Int
{
return
distances
.
firstIndex
{
$0
==
Settings
.
shared
.
distanceType
}
??
-
1
}
public
var
selectedRainfallIndex
:
Int
{
return
rainFalls
.
firstIndex
{
$0
==
Settings
.
shared
.
rainfallType
}
??
-
1
}
public
var
selectedLanguageIndex
:
Int
{
return
Localize
.
availableLanguages
()
.
firstIndex
{
$0
==
Localize
.
currentLanguage
()
}
??
-
1
}
...
...
BlendMinutelySource/BlendMinutelySource/BlendMinutelySource.swift
View file @
a989dda1
...
...
@@ -139,7 +139,7 @@ public class BlendMinutelySource: MinutelyForecastSource {
private
func
covnertToAppModel
(
itemToConvert
:
BlendMinutelyForecast
)
->
MinutelyForecast
{
let
items
=
itemToConvert
.
forecast
.
map
{
MinutelyItem
(
time
:
$0
.
time
,
temp
:
.
init
(
value
:
Double
(
$0
.
temp
),
unit
:
.
fahrenheit
),
precipitation
:
$0
.
precipitation
,
precipitation
:
.
init
(
value
:
$0
.
precipitation
,
unit
:
.
inchesPerHour
)
,
windSpeed
:
.
init
(
value
:
Double
(
$0
.
windSpeed
),
unit
:
.
milesPerHour
),
pressure
:
.
init
(
value
:
Double
(
$0
.
pressure
),
unit
:
.
inchesOfMercury
))
}
let
minutelyForecast
=
MinutelyForecast
(
lastUpdateTime
:
Date
(),
...
...
OneWeatherCore/OneWeatherCore/Extensions/Dimension+Name.swift
View file @
a989dda1
...
...
@@ -14,7 +14,18 @@ public extension Dimension {
return
fmt
}
var
name
:
String
{
var
name
:
String
{
if
let
unitRainfall
=
self
as?
UnitRainfall
{
switch
unitRainfall
{
case
.
inchesPerHour
:
return
"inches per hour"
case
.
millimetersPerHour
:
return
"millimeters per hour"
default
:
return
Dimension
.
fmt
.
string
(
from
:
self
)
}
}
return
Dimension
.
fmt
.
string
(
from
:
self
)
}
}
...
...
OneWeatherCore/OneWeatherCore/HelperTypes.swift
View file @
a989dda1
...
...
@@ -343,6 +343,13 @@ public enum MoonPhase: String, Codable {
}
}
public
class
UnitRainfall
:
Dimension
{
public
static
let
inchesPerHour
=
UnitRainfall
(
symbol
:
"in/h"
,
converter
:
UnitConverterLinear
(
coefficient
:
1.0
))
public
static
let
millimetersPerHour
=
UnitRainfall
(
symbol
:
"mm/h"
,
converter
:
UnitConverterLinear
(
coefficient
:
25.4
))
public
static
let
baseUnit
=
UnitRainfall
.
inchesPerHour
}
public
struct
Time
:
CustomStringConvertible
,
Codable
{
public
let
hours
:
UInt8
public
let
minutes
:
UInt8
...
...
@@ -433,6 +440,7 @@ public typealias WindSpeed = Measurement<UnitSpeed>
public
typealias
Percent
=
UInt
public
typealias
Visibility
=
Measurement
<
UnitLength
>
public
typealias
Pressure
=
Measurement
<
UnitPressure
>
public
typealias
Rainfall
=
Measurement
<
UnitRainfall
>
extension
Measurement
{
public
init
?(
valueString
:
String
?,
unit
:
UnitType
)
{
...
...
OneWeatherCore/OneWeatherCore/ModelObjects/Minutely/MinutelyItem.swift
View file @
a989dda1
...
...
@@ -11,12 +11,12 @@ import UIKit
public
struct
MinutelyItem
{
public
let
time
:
Date
public
let
temp
:
Temperature
public
let
precipitation
:
Double
public
let
precipitation
:
Rainfall
public
let
windSpeed
:
WindSpeed
public
let
pressure
:
Pressure
public
var
weatherTypeImage
:
UIImage
?
public
init
(
time
:
Date
,
temp
:
Temperature
,
precipitation
:
Double
,
windSpeed
:
WindSpeed
,
pressure
:
Pressure
)
{
public
init
(
time
:
Date
,
temp
:
Temperature
,
precipitation
:
Rainfall
,
windSpeed
:
WindSpeed
,
pressure
:
Pressure
)
{
self
.
time
=
time
self
.
temp
=
temp
self
.
precipitation
=
precipitation
...
...
OneWeatherCore/OneWeatherCore/Settings/DefaultSettings/DefaultSettings.swift
View file @
a989dda1
...
...
@@ -12,6 +12,7 @@ public protocol DefaultSettings {
var
windSpeedType
:
UnitSpeed
{
get
}
var
pressureType
:
UnitPressure
{
get
}
var
distanceType
:
UnitLength
{
get
}
var
rainfallType
:
UnitRainfall
{
get
}
var
pinnedLayerIds
:
[
String
]
{
get
}
var
selectedLayerId
:
String
{
get
}
}
OneWeatherCore/OneWeatherCore/Settings/DefaultSettings/DefaultSettingsImperial.swift
View file @
a989dda1
...
...
@@ -12,6 +12,7 @@ struct DefaultSettingsImperial: DefaultSettings {
let
windSpeedType
:
UnitSpeed
=
.
milesPerHour
let
pressureType
:
UnitPressure
=
.
inchesOfMercury
let
distanceType
:
UnitLength
=
.
miles
let
rainfallType
:
UnitRainfall
=
.
inchesPerHour
let
pinnedLayerIds
:
[
String
]
=
[]
let
selectedLayerId
:
String
=
WeatherLayerType
.
surfaceTemp
.
rawValue
}
OneWeatherCore/OneWeatherCore/Settings/DefaultSettings/DefaultSettingsMetric.swift
View file @
a989dda1
...
...
@@ -12,6 +12,7 @@ struct DefaultSettingsMetric: DefaultSettings {
let
windSpeedType
:
UnitSpeed
=
.
metersPerSecond
let
pressureType
:
UnitPressure
=
.
millimetersOfMercury
let
distanceType
:
UnitLength
=
.
kilometers
let
rainfallType
:
UnitRainfall
=
.
millimetersPerHour
let
pinnedLayerIds
:
[
String
]
=
[]
let
selectedLayerId
:
String
=
WeatherLayerType
.
surfaceTemp
.
rawValue
}
OneWeatherCore/OneWeatherCore/Settings/Settings.swift
View file @
a989dda1
...
...
@@ -67,6 +67,9 @@ public class Settings {
@UserDefaultsUnitValue(key: "distance_type", userDefaults: UserDefaults.appDefaults)
public
var
distanceType
=
DefaultSettingsFactory
()
.
getSettings
()
.
distanceType
@UserDefaultsUnitValue(key: "rainfall_type", userDefaults: UserDefaults.appDefaults)
public
var
rainfallType
=
DefaultSettingsFactory
()
.
getSettings
()
.
rainfallType
public
var
locale
:
Locale
{
return
Locale
(
identifier
:
Localize
.
currentLanguage
())
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment