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
a6eedde5
Commit
a6eedde5
authored
Jul 06, 2021
by
Dmitriy Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved MediumWidget to OneWeatherUI module
parent
e5533185
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
9 deletions
+46
-9
1Weather/Resources/en.lproj/Localizable.strings
+2
-0
OneWeatherUI/OneWeatherUI/Widgets/MediumTemperatureWidgetView.swift
+27
-7
OneWeatherWidget/UI/WidgetPlaceholderView.swift
+3
-0
OneWeatherWidget/Widgets/MediumTemperatureWidget.swift
+13
-1
OneWeatherWidget/Widgets/SmallTemperatureWidget.swift
+1
-1
No files found.
1Weather/Resources/en.lproj/Localizable.strings
View file @
a6eedde5
...
@@ -287,4 +287,6 @@
...
@@ -287,4 +287,6 @@
//Widget
//Widget
"widget.small.title" = "Temperature Forecast";
"widget.small.title" = "Temperature Forecast";
"widget.small.description" = "";
"widget.small.description" = "";
"widget.medium.title" = "Temperature Forecast";
"widget.medium.description" = "";
"widget.lastUpdatedTemplate" = "Last updated #LAST_UPDATED ago.";
"widget.lastUpdatedTemplate" = "Last updated #LAST_UPDATED ago.";
OneWeatherUI/OneWeatherUI/Widgets/MediumTemperatureWidgetView.swift
View file @
a6eedde5
...
@@ -9,20 +9,25 @@ import SwiftUI
...
@@ -9,20 +9,25 @@ import SwiftUI
import
WidgetKit
import
WidgetKit
@available
(
iOS
14
,
*
)
@available
(
iOS
14
,
*
)
struct
MediumTemperatureWidgetView
:
View
{
public
struct
MediumTemperatureWidgetView
:
View
{
//Public
//Public
let
widgetViewModel
:
WidgetViewModel
let
widgetViewModel
:
WidgetViewModel
public
init
(
widgetViewModel
:
WidgetViewModel
?)
{
self
.
widgetViewModel
=
widgetViewModel
??
WidgetViewModelMock
()
}
//Private
@Environment(\.colorScheme)
private
var
colorScheme
@Environment(\.colorScheme)
private
var
colorScheme
var
body
:
some
View
{
public
var
body
:
some
View
{
GeometryReader
{
geometry
in
GeometryReader
{
geometry
in
VStack
(
alignment
:
.
leading
)
{
VStack
(
alignment
:
.
leading
)
{
HStack
{
HStack
{
HStack
(
spacing
:
8
)
{
HStack
(
spacing
:
8
)
{
Text
(
widgetViewModel
.
temperature
)
Text
(
widgetViewModel
.
temperature
)
.
font
(
WidgetFont
.
SFProDisplay
.
light
(
size
:
32
)
.
font
)
.
font
(
WidgetFont
.
SFProDisplay
.
light
(
size
:
32
)
.
font
)
foregroundColor
(
Color
(
"PrimaryTextColor"
,
.
foregroundColor
(
Color
(
"PrimaryTextColor"
,
bundle
:
OneWeatherUI
.
frameworkBundle
))
bundle
:
OneWeatherUI
.
frameworkBundle
))
Divider
()
Divider
()
.
padding
(
.
top
,
8
)
.
padding
(
.
top
,
8
)
...
@@ -34,17 +39,15 @@ struct MediumTemperatureWidgetView: View {
...
@@ -34,17 +39,15 @@ struct MediumTemperatureWidgetView: View {
bundle
:
OneWeatherUI
.
frameworkBundle
))
bundle
:
OneWeatherUI
.
frameworkBundle
))
.
lineLimit
(
2
)
.
lineLimit
(
2
)
Image
(
uiImage
:
widgetViewModel
.
weatherIcon
)
weatherImage
(
uiImage
:
widgetViewModel
.
weatherIcon
)
.
resizable
()
.
aspectRatio
(
contentMode
:
.
fit
)
.
aspectRatio
(
contentMode
:
.
fit
)
.
frame
(
width
:
30
,
height
:
30
,
alignment
:
.
center
)
.
frame
(
width
:
30
,
height
:
30
,
alignment
:
.
center
)
.
shadow
(
color
:
Color
.
black
.
opacity
(
0.23
),
radius
:
16
,
x
:
2
,
y
:
0
)
.
shadow
(
for
:
colorScheme
)
.
padding
(
.
trailing
,
4
)
.
padding
(
.
trailing
,
4
)
}
}
Spacer
()
Spacer
()
VStack
(
spacing
:
2
)
{
VStack
(
spacing
:
2
)
{
CityNameView
(
cityName
:
widgetViewModel
.
cityName
,
isDeviceLocation
:
widgetViewModel
.
isDeviceLocation
)
CityNameView
(
cityName
:
widgetViewModel
.
cityName
,
isDeviceLocation
:
widgetViewModel
.
isDeviceLocation
)
HighLowTemperatureView
(
highTemperature
:
widgetViewModel
.
highTemperature
,
lowTemperature
:
widgetViewModel
.
lowTemperature
)
HighLowTemperatureView
(
highTemperature
:
widgetViewModel
.
highTemperature
,
lowTemperature
:
widgetViewModel
.
lowTemperature
)
}
}
.
frame
(
height
:
35
)
.
frame
(
height
:
35
)
...
@@ -69,7 +72,24 @@ struct MediumTemperatureWidgetView: View {
...
@@ -69,7 +72,24 @@ struct MediumTemperatureWidgetView: View {
.
padding
([
.
leading
,
.
trailing
],
10
)
.
padding
([
.
leading
,
.
trailing
],
10
)
}
}
}
}
}
@available(iOS 14, *)
private
extension
View
{
func
shadow
(
for
colorScheme
:
ColorScheme
)
->
some
View
{
switch
colorScheme
{
case
.
light
:
return
self
.
shadow
(
color
:
Color
.
black
.
opacity
(
0.5
),
radius
:
16
,
x
:
2
,
y
:
0
)
case
.
dark
:
return
self
.
shadow
(
color
:
Color
.
white
.
opacity
(
0.24
),
radius
:
16
,
x
:
2
,
y
:
0
)
@unknown
default
:
return
self
.
shadow
(
color
:
Color
.
black
.
opacity
(
0.5
),
radius
:
16
,
x
:
2
,
y
:
0
)
}
}
func
weatherImage
(
uiImage
:
UIImage
)
->
Image
{
return
Image
(
uiImage
:
uiImage
.
scalePreservingAspectRatio
(
targetSize
:
.
init
(
width
:
30
,
height
:
30
)))
}
}
}
@available(iOS 14, *)
@available(iOS 14, *)
...
...
OneWeatherWidget/UI/WidgetPlaceholderView.swift
View file @
a6eedde5
...
@@ -17,6 +17,9 @@ struct WidgetPlaceholderView: View {
...
@@ -17,6 +17,9 @@ struct WidgetPlaceholderView: View {
case
.
systemSmall
:
case
.
systemSmall
:
SmallTemperatureWidgetView
(
widgetViewModel
:
ForecastWidgetViewModel
(
location
:
WeatherEntry
.
defaultLocation
))
SmallTemperatureWidgetView
(
widgetViewModel
:
ForecastWidgetViewModel
(
location
:
WeatherEntry
.
defaultLocation
))
.
redacted
(
reason
:
.
placeholder
)
.
redacted
(
reason
:
.
placeholder
)
case
.
systemMedium
:
MediumTemperatureWidgetView
(
widgetViewModel
:
ForecastWidgetViewModel
(
location
:
WeatherEntry
.
defaultLocation
))
.
redacted
(
reason
:
.
placeholder
)
default
:
default
:
SmallTemperatureWidgetView
(
widgetViewModel
:
ForecastWidgetViewModel
(
location
:
WeatherEntry
.
defaultLocation
))
SmallTemperatureWidgetView
(
widgetViewModel
:
ForecastWidgetViewModel
(
location
:
WeatherEntry
.
defaultLocation
))
.
redacted
(
reason
:
.
placeholder
)
.
redacted
(
reason
:
.
placeholder
)
...
...
OneWeatherWidget/Widgets/MediumTemperatureWidget.swift
View file @
a6eedde5
...
@@ -7,13 +7,25 @@
...
@@ -7,13 +7,25 @@
import
SwiftUI
import
SwiftUI
import
WidgetKit
import
WidgetKit
import
OneWeatherUI
struct
MediumTemperatureWidget
:
Widget
{
struct
MediumTemperatureWidget
:
Widget
{
private
let
kind
=
"com.onelouder.oneweather.widget.medium.temperature"
private
let
kind
=
"com.onelouder.oneweather.widget.medium.temperature"
var
body
:
some
WidgetConfiguration
{
var
body
:
some
WidgetConfiguration
{
StaticConfiguration
(
kind
:
kind
,
provider
:
WeatherProvider
())
{
weatherEntry
in
StaticConfiguration
(
kind
:
kind
,
provider
:
WeatherProvider
())
{
weatherEntry
in
MediumTemperatureWidgetView
(
widgetViewModel
:
.
init
(
location
:
weatherEntry
.
location
))
MediumTemperatureWidgetView
(
widgetViewModel
:
ForecastWidgetViewModel
(
location
:
weatherEntry
.
location
))
}
}
.
configurationDisplayName
(
"widget.medium.title"
.
localized
())
.
description
(
"widget.medium.description"
.
localized
())
.
supportedFamilies
([
.
systemMedium
])
.
supportedFamilies
([
.
systemMedium
])
}
}
}
}
struct
MediumTemperatureWidgetView_Preview
:
PreviewProvider
{
public
static
var
previews
:
some
View
{
MediumTemperatureWidgetView
(
widgetViewModel
:
nil
)
.
previewContext
(
WidgetPreviewContext
(
family
:
.
systemMedium
))
}
}
OneWeatherWidget/Widgets/SmallTemperatureWidget.swift
View file @
a6eedde5
...
@@ -11,7 +11,7 @@ import OneWeatherUI
...
@@ -11,7 +11,7 @@ import OneWeatherUI
import
Localize_Swift
import
Localize_Swift
struct
SmallTemperatureWidget
:
Widget
{
struct
SmallTemperatureWidget
:
Widget
{
private
let
kind
=
"com.onelouder.oneweather.widget.small"
private
let
kind
=
"com.onelouder.oneweather.widget.small
.temperature
"
var
body
:
some
WidgetConfiguration
{
var
body
:
some
WidgetConfiguration
{
// We currently display selectedLocation, so it's not really configurable, but we'll probably need to switch to an IntentConfiguration at some point.
// We currently display selectedLocation, so it's not really configurable, but we'll probably need to switch to an IntentConfiguration at some point.
...
...
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