Skip to content

Commit

Permalink
Adjustments for Apple changes in dynamic wallpapers.
Browse files Browse the repository at this point in the history
  • Loading branch information
mczachurski committed Jul 31, 2018
1 parent 720d28e commit 7fac6cf
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 20 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ swift build --configuration release
sudo cp .build/x86_64-apple-macosx10.10/release/wallpapper /usr/local/bin
```

If you are using swift in version 4.1, please edit `Package.swift` file and put there your version of swift (in first line).

Now in the console you can run `wallpapper -h` and you should got a response similar to the following one.

```bash
Expand All @@ -39,13 +41,17 @@ If you have done above commands now you can build dynamic wallpaper. It's really
{
"fileName": "1.png",
"isPrimary": true,
"isForLight": true,
"isForDark": false,
"themeMode": 1,
"altitude": 27.95,
"azimuth": 279.66
},
{
"fileName": "2.png",
"isPrimary": false,
"isForLight": false,
"isForDark": false,
"themeMode": 1,
"altitude": -31.05,
"azimuth": 4.16
Expand All @@ -54,6 +60,8 @@ If you have done above commands now you can build dynamic wallpaper. It's really
{
"fileName": "16.png",
"isPrimary": false,
"isForLight": false,
"isForDark": true,
"themeMode": 1,
"altitude": -28.63,
"azimuth": 340.41
Expand All @@ -65,7 +73,8 @@ Properties:

- `fileName` - name of picture file name.
- `isPrimary` - information about image which is primary image (it will be visible after creating `heic` file). Only one of the file can be primary.
- `themeMode` - information about mode which will display picture. 0 - picture will be displayed in both modes (light/dark). 1 - picture will be displayed only in light mode.
- `isForLight` - if `true` picture will be displayed when user chose "Light (static)" wallpaper
- `isForDark` - if `true` picture will be displayed when user chose "Dark (static)" wallpaper
- `altitude` - is the angle between the Sun and the observer's local horizon.
- `azimuth` - that is the angle of the Sun around the horizon.

Expand Down
9 changes: 8 additions & 1 deletion Sources/wallpapper/Generator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,16 @@ class Generator {
let sequenceItem = SequenceItem()
sequenceItem.a = item.altitude
sequenceItem.z = item.azimuth
sequenceItem.o = item.themeMode == .both ? 0 : 1
sequenceItem.i = index

if item.isForLight {
sequenceInfo.ap.l = index
}

if item.isForDark {
sequenceInfo.ap.d = index
}

sequenceInfo.si.append(sequenceItem)
}

Expand Down
8 changes: 5 additions & 3 deletions Sources/wallpapper/Model/PictureInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ import Foundation
class PictureInfo: Decodable {
var fileName: String
var isPrimary = false
var themeMode: ThemeMode = .both
var isForLight = false
var isForDark = false
var altitude = 0.0
var azimuth = 0.0

init(fileName: String, isPrimary: Bool, themeMode: ThemeMode, altitude: Double, azimuth: Double) {
init(fileName: String, isPrimary: Bool, isForLight: Bool, isForDark: Bool, altitude: Double, azimuth: Double) {
self.fileName = fileName
self.isPrimary = isPrimary
self.themeMode = themeMode
self.isForLight = isForLight
self.isForDark = isForDark
self.altitude = altitude
self.azimuth = azimuth
}
Expand Down
14 changes: 0 additions & 14 deletions Sources/wallpapper/Model/ThemeMode.swift

This file was deleted.

13 changes: 13 additions & 0 deletions Sources/wallpapper/PropertyList/Apperance.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// Apperance.swift
// wallpapper
//
// Created by Marcin Czachurski on 31/07/2018.
//

import Foundation

class Apperance: Codable {
var d: Int = 0
var l: Int = 0
}
1 change: 1 addition & 0 deletions Sources/wallpapper/PropertyList/SequenceInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ import Foundation

class SequenceInfo : Codable {
var si: [SequenceItem] = []
var ap = Apperance()
}
1 change: 0 additions & 1 deletion Sources/wallpapper/PropertyList/SequenceItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ class SequenceItem : Codable {
var a: Double = 0.0
var z: Double = 0.0
var i: Int = 0
var o: Int = 0
}

0 comments on commit 7fac6cf

Please sign in to comment.