Skip to content

Commit d9ea267

Browse files
authored
Merge pull request #6 from mulot/developpement
Developpement
2 parents 4d12c16 + bb3a9c1 commit d9ea267

File tree

16 files changed

+556
-75
lines changed

16 files changed

+556
-75
lines changed

BeatTime.xcodeproj/project.pbxproj

Lines changed: 193 additions & 17 deletions
Large diffs are not rendered by default.

BeatTime.xcodeproj/xcuserdata/mulot.xcuserdatad/xcschemes/xcschememanagement.plist

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>BeatTimeMenuBar.xcscheme_^#shared#^_</key>
1818
<dict>
1919
<key>orderHint</key>
20-
<integer>9</integer>
20+
<integer>10</integer>
2121
</dict>
2222
<key>BeatTimeTvOS.xcscheme_^#shared#^_</key>
2323
<dict>
@@ -49,6 +49,11 @@
4949
<key>orderHint</key>
5050
<integer>6</integer>
5151
</dict>
52+
<key>BeatTimeWidgetWatchOSExtension.xcscheme_^#shared#^_</key>
53+
<dict>
54+
<key>orderHint</key>
55+
<integer>9</integer>
56+
</dict>
5257
<key>BeatTimeWidgetiOSExtension.xcscheme_^#shared#^_</key>
5358
<dict>
5459
<key>orderHint</key>
@@ -62,6 +67,26 @@
6267
</dict>
6368
<key>SuppressBuildableAutocreation</key>
6469
<dict>
70+
<key>94196330292ED5FE009BC68A</key>
71+
<dict>
72+
<key>primary</key>
73+
<true/>
74+
</dict>
75+
<key>947C5629264814E9007E6B4A</key>
76+
<dict>
77+
<key>primary</key>
78+
<true/>
79+
</dict>
80+
<key>947C562C264814E9007E6B4A</key>
81+
<dict>
82+
<key>primary</key>
83+
<true/>
84+
</dict>
85+
<key>94BEB1B92646D9C500A5D811</key>
86+
<dict>
87+
<key>primary</key>
88+
<true/>
89+
</dict>
6590
<key>94CBA0C3265308370032CA8B</key>
6691
<dict>
6792
<key>primary</key>

BeatTime/BeatTime.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,18 @@ class BeatTime: NSObject {
7878
}
7979
return(Date())
8080
}
81+
82+
/// Return the difference between LocalTimeZone and GMT
83+
/// - Parameter date: local date
84+
/// - Returns: Difference in hours (negative or positive)
85+
static func hoursOffsetWithGMT(date: Date = Date()) -> Int
86+
{
87+
//print(TimeZone.current.identifier)
88+
//print(TimeZone.abbreviationDictionary)
89+
//let seconds = TimeZone.init(identifier: "JST")!.secondsFromGMT(for: date)
90+
let seconds = TimeZone.current.secondsFromGMT(for: date)
91+
let hours = seconds / 3600
92+
//print("seconds: \(seconds) hours: \(hours)")
93+
return(hours)
94+
}
8195
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"platform" : "watchos",
6+
"size" : "1024x1024"
7+
}
8+
],
9+
"info" : {
10+
"author" : "xcode",
11+
"version" : 1
12+
}
13+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}

BeatTimeWidgetWatchOS/Info.plist

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>NSExtension</key>
6+
<dict>
7+
<key>NSExtensionPointIdentifier</key>
8+
<string>com.apple.widgetkit-extension</string>
9+
</dict>
10+
</dict>
11+
</plist>

MacOS/AppDelegate.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class AppDelegate: NSObject, NSWindowDelegate, NSApplicationDelegate {
2121
var circleView: RingProgressView!
2222
var isCentiBeats: Bool = false
2323
var statusItem: NSStatusItem?
24+
var lineWidth: CGFloat = 25
2425

2526
@IBAction func changeCentiBeats(_ sender: AnyObject) {
2627
if (beat != nil) {
@@ -45,6 +46,7 @@ class AppDelegate: NSObject, NSWindowDelegate, NSApplicationDelegate {
4546
circle.arcFrag = 1000
4647
circle.lineColor = NSColor.gray.cgColor
4748
circle.isShadow = true
49+
circle.lineWidth = lineWidth
4850
if (circleView != nil) {
4951
view.replaceSubview(circleView, with: circle)
5052
circleView = circle
@@ -57,6 +59,7 @@ class AppDelegate: NSObject, NSWindowDelegate, NSApplicationDelegate {
5759
let circleBeat = RingProgressView(frame: NSRect(x: window.contentLayoutRect.width/2 - (circleDiameter/2), y: window.contentLayoutRect.height/2 - (circleDiameter/2), width: circleDiameter, height: circleDiameter))
5860
if (beat != nil) {
5961
circleBeat.arcFrag = Double(beat.beats()) ?? 0
62+
circleBeat.lineWidth = lineWidth
6063
//circleBeat.arcFrag = 999 // TEST FULL CIRCLE
6164
}
6265
if (circleBeatView != nil) {

TvOS/BeatTimeTvOSApp.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,15 @@ struct ContentView: View {
3333
.font(.title.bold())
3434
.gradientForeground(colors: [.startGradient, .midGradient, .mid2Gradient, .endGradient])
3535
*/
36-
BeatTimeView(lineWidth: 40)
37-
36+
if #available(tvOS 16.0, *) {
37+
BeatTimeView(lineWidth: 40)
38+
.onTapGesture {
39+
print("Tap")
40+
}
41+
}
42+
else {
43+
BeatTimeView(lineWidth: 40)
44+
}
3845
}
3946
}
4047
}

View/BeatTImeView.swift

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct BeatTimeView: View {
3232
}
3333
if (Double(beats) != nil) {
3434
RingProgressView(arcFrag: Double(beats)!, lineWidth: lineWidth)
35-
.gradientForeground(colors: [.startGradient, .midGradient, .mid2Gradient, .endGradient], startPoint: startGradient, endPoint: endGradient)
35+
.gradientLinear(colors: [.startGradient, .midGradient, .mid2Gradient, .endGradient], startPoint: startGradient, endPoint: endGradient)
3636
.onAppear() {
3737
withAnimation(.default.speed(0.30)) {
3838
//print("animation on Appear")
@@ -60,7 +60,7 @@ struct BeatTimeView: View {
6060
#endif*/
6161
}
6262
TextFitView(text: "@" + beats, size: displayLenght)
63-
.gradientForeground(colors: [.startGradient, .midGradient, .mid2Gradient, .endGradient])
63+
.gradientLinear(colors: [.startGradient, .midGradient, .mid2Gradient, .endGradient])
6464
/*Text("@" + beats)
6565
.font(.largeTitle.bold())
6666
.font(.system(size: fontSize, weight: .bold))*/
@@ -86,8 +86,8 @@ struct BeatTimeView: View {
8686

8787
func gradientPosition(date: Date = Date(), frame: CGRect, lenght: CGFloat, followSun: Bool = true) -> (UnitPoint, UnitPoint)
8888
{
89-
let nbHour = hoursOffsetWithGMT()
90-
let angle = (2 * Double.pi) / 24 * Double(nbHour)
89+
let nbHour = BeatTime.hoursOffsetWithGMT()
90+
let angle = -(2 * Double.pi) / 24 * Double(nbHour)
9191
let r = lenght / 2
9292
let startCircle = UnitPoint(x: 0.5, y: (1 - (lenght / frame.height)) / 2)
9393
let endCircle = UnitPoint(x: 0.5, y: 1 - ((1 - (lenght / frame.height)) / 2))
@@ -105,18 +105,6 @@ struct BeatTimeView: View {
105105
return (startCircle, endCircle)
106106
}
107107
}
108-
109-
110-
func hoursOffsetWithGMT(date: Date = Date()) -> Int
111-
{
112-
//print(TimeZone.current.identifier)
113-
//print(TimeZone.abbreviationDictionary)
114-
//let seconds = TimeZone.init(identifier: "JST")!.secondsFromGMT(for: date)
115-
let seconds = TimeZone.current.secondsFromGMT(for: date)
116-
let hours = seconds / 3600
117-
//print("seconds: \(seconds) hours: \(-hours)")
118-
return(-hours)
119-
}
120108
}
121109

122110
struct BeatTime_Previews: PreviewProvider {

View/Colors.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import SwiftUI
1010
extension Color {
1111
static let timeLine = Color.orange
1212
static let circleLine = Color(red: 230/255, green: 230/255, blue: 230/255)
13-
static let startGradient = Color(red: 0, green: 30/255, blue: 50/255)
13+
static let startGradient = Color(red: 0, green: 30/255, blue: 50/255) // midnight
1414
static let midGradient = Color.purple
15-
static let mid2Gradient = Color(red: 247/255, green: 186/255, blue: 0)
16-
static let endGradient = Color(red: 1, green: 1, blue: 0)
15+
static let mid2Gradient = Color(red: 247/255, green: 186/255, blue: 0) // neaar orange
16+
static let endGradient = Color(red: 1, green: 1, blue: 0) // yellow
1717
}

View/UIViewDraw.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@
99
import SwiftUI
1010

1111
extension View {
12-
public func gradientForeground(colors: [Color], startPoint: UnitPoint = .top, endPoint: UnitPoint = .bottom) -> some View {
13-
self.overlay(LinearGradient(gradient: .init(colors: colors),
14-
startPoint: startPoint,
15-
endPoint: endPoint))
12+
public func gradientLinear(colors: [Color], startPoint: UnitPoint = .top, endPoint: UnitPoint = .bottom) -> some View {
13+
self.overlay(LinearGradient(gradient: .init(colors: colors),
14+
startPoint: startPoint,
15+
endPoint: endPoint))
1616
.mask(self)
1717
}
18+
public func gradientRadius(colors: [Color], center: UnitPoint = .center, startRadius: CGFloat = 0, endRadius: CGFloat = 1) -> some View {
19+
self.overlay(RadialGradient(gradient: .init(colors: colors),
20+
center: center, startRadius: startRadius, endRadius: endRadius))
21+
.mask(self)
22+
}
1823
}
1924

2025
struct RingProgressView: Shape {

WatchOS WatchKit Extension/BeatTimeApp.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,20 @@ struct ContentView: View {
174174
*/
175175
ProgressView(value: Double(beats)!/1000)
176176
.progressViewStyle(CircularProgressViewStyle(tint: fgColors[Int(index.rounded())]))
177-
//.scaledToFit()
177+
//.gradientLinear(colors: [.startGradient, .midGradient, .mid2Gradient, .endGradient])
178+
//.scaledToFit()
178179
.frame(width: frame.width, height: frame.height, alignment: .center)
179180
.scaleEffect(3.2, anchor: .center)
180181
.onAppear() {
181182
withAnimation(.default.speed(0.25)) {
182183
self.beats = BeatTime().beats()
183-
print("animation on Appear")
184+
//print("animation on Appear")
184185
}
185186
}
186187
Text("@" + beats)
187188
.font(.title.bold())
188189
.foregroundColor(fgColors[Int(index.rounded())])
190+
//.gradientLinear(colors: [.startGradient, .midGradient, .mid2Gradient, .endGradient])
189191
//Text("Index : \(index)")
190192
}
191193
.focusable()

0 commit comments

Comments
 (0)