added loading screen before showing full views

This commit is contained in:
Andy Pack 2022-12-10 11:52:03 +00:00
parent 8f103fab3e
commit afee0ecea4
Signed by: sarsoo
GPG Key ID: A55BA3536A5E0ED7
4 changed files with 93 additions and 35 deletions

View File

@ -14,6 +14,7 @@
A15D257C293425390049055E /* NotificationsControls.swift in Sources */ = {isa = PBXBuildFile; fileRef = A15D257B293425390049055E /* NotificationsControls.swift */; }; A15D257C293425390049055E /* NotificationsControls.swift in Sources */ = {isa = PBXBuildFile; fileRef = A15D257B293425390049055E /* NotificationsControls.swift */; };
A15D257E29342E4F0049055E /* APNSHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = A15D257D29342E4F0049055E /* APNSHandler.swift */; }; A15D257E29342E4F0049055E /* APNSHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = A15D257D29342E4F0049055E /* APNSHandler.swift */; };
A15D258029342EF50049055E /* NetworkHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = A15D257F29342EF50049055E /* NetworkHelper.swift */; }; A15D258029342EF50049055E /* NetworkHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = A15D257F29342EF50049055E /* NetworkHelper.swift */; };
A1846C4329449A8800028978 /* LoadingScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1846C4229449A8800028978 /* LoadingScreen.swift */; };
A1AF726F28A84F7D00D317C9 /* AdminApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1AF726E28A84F7D00D317C9 /* AdminApi.swift */; }; A1AF726F28A84F7D00D317C9 /* AdminApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1AF726E28A84F7D00D317C9 /* AdminApi.swift */; };
A1AF727128A850AE00D317C9 /* UsersList.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1AF727028A850AE00D317C9 /* UsersList.swift */; }; A1AF727128A850AE00D317C9 /* UsersList.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1AF727028A850AE00D317C9 /* UsersList.swift */; };
A1AF727328A9062600D317C9 /* UserView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1AF727228A9062600D317C9 /* UserView.swift */; }; A1AF727328A9062600D317C9 /* UserView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1AF727228A9062600D317C9 /* UserView.swift */; };
@ -79,6 +80,7 @@
A15D257B293425390049055E /* NotificationsControls.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationsControls.swift; sourceTree = "<group>"; }; A15D257B293425390049055E /* NotificationsControls.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationsControls.swift; sourceTree = "<group>"; };
A15D257D29342E4F0049055E /* APNSHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APNSHandler.swift; sourceTree = "<group>"; }; A15D257D29342E4F0049055E /* APNSHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APNSHandler.swift; sourceTree = "<group>"; };
A15D257F29342EF50049055E /* NetworkHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkHelper.swift; sourceTree = "<group>"; }; A15D257F29342EF50049055E /* NetworkHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkHelper.swift; sourceTree = "<group>"; };
A1846C4229449A8800028978 /* LoadingScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingScreen.swift; sourceTree = "<group>"; };
A1AF726E28A84F7D00D317C9 /* AdminApi.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminApi.swift; sourceTree = "<group>"; }; A1AF726E28A84F7D00D317C9 /* AdminApi.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminApi.swift; sourceTree = "<group>"; };
A1AF727028A850AE00D317C9 /* UsersList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UsersList.swift; sourceTree = "<group>"; }; A1AF727028A850AE00D317C9 /* UsersList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UsersList.swift; sourceTree = "<group>"; };
A1AF727228A9062600D317C9 /* UserView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserView.swift; sourceTree = "<group>"; }; A1AF727228A9062600D317C9 /* UserView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserView.swift; sourceTree = "<group>"; };
@ -205,6 +207,7 @@
E9E30C2E23FEACDE00574EEF /* Playlist */, E9E30C2E23FEACDE00574EEF /* Playlist */,
E9EA690E23F9A5430012C3E8 /* AppSkeleton.swift */, E9EA690E23F9A5430012C3E8 /* AppSkeleton.swift */,
E98254CF23FB00B60056D9D3 /* LoginScreen.swift */, E98254CF23FB00B60056D9D3 /* LoginScreen.swift */,
A1846C4229449A8800028978 /* LoadingScreen.swift */,
); );
path = Views; path = Views;
sourceTree = "<group>"; sourceTree = "<group>";
@ -469,6 +472,7 @@
E9EA690B23F9A5430012C3E8 /* AppDelegate.swift in Sources */, E9EA690B23F9A5430012C3E8 /* AppDelegate.swift in Sources */,
E906F7F42414019C004E1E31 /* NetworkPersister.swift in Sources */, E906F7F42414019C004E1E31 /* NetworkPersister.swift in Sources */,
A15D258029342EF50049055E /* NetworkHelper.swift in Sources */, A15D258029342EF50049055E /* NetworkHelper.swift in Sources */,
A1846C4329449A8800028978 /* LoadingScreen.swift in Sources */,
A1AF727328A9062600D317C9 /* UserView.swift in Sources */, A1AF727328A9062600D317C9 /* UserView.swift in Sources */,
E9E30C3323FF255C00574EEF /* SettingsList.swift in Sources */, E9E30C3323FF255C00574EEF /* SettingsList.swift in Sources */,
E9EA690D23F9A5430012C3E8 /* SceneDelegate.swift in Sources */, E9EA690D23F9A5430012C3E8 /* SceneDelegate.swift in Sources */,

View File

@ -47,6 +47,10 @@ class LiveUser: ObservableObject {
Logger.sys.debug("failed to get APNS token") Logger.sys.debug("failed to get APNS token")
} }
@Published var isInitiallyRefreshingUser = true
@Published var isInitiallyRefreshingPlaylists = true
@Published var isInitiallyRefreshingTags = true
@Published var isRefreshingUser = false @Published var isRefreshingUser = false
@Published var isRefreshingPlaylists = false @Published var isRefreshingPlaylists = false
@Published var isRefreshingTags = false @Published var isRefreshingTags = false
@ -128,6 +132,7 @@ class LiveUser: ObservableObject {
self.user = UserApi.fromJSON(user: json) self.user = UserApi.fromJSON(user: json)
self.isRefreshingUser = false self.isRefreshingUser = false
self.isInitiallyRefreshingUser = false
if let success = onSuccess { if let success = onSuccess {
Logger.sys.debug("successfully refreshed user") Logger.sys.debug("successfully refreshed user")
@ -170,6 +175,7 @@ class LiveUser: ObservableObject {
self.playlists = PlaylistApi.fromJSON(playlist: playlists).sorted(by: { $0.name.lowercased() < $1.name.lowercased() }) self.playlists = PlaylistApi.fromJSON(playlist: playlists).sorted(by: { $0.name.lowercased() < $1.name.lowercased() })
self.isRefreshingPlaylists = false self.isRefreshingPlaylists = false
self.isInitiallyRefreshingPlaylists = false
if let success = onSuccess { if let success = onSuccess {
Logger.sys.debug("successfully refreshed playlists") Logger.sys.debug("successfully refreshed playlists")
@ -219,6 +225,7 @@ class LiveUser: ObservableObject {
self.tags = TagApi.fromJSON(tag: tags).sorted(by: { $0.name.lowercased() < $1.name.lowercased() }) self.tags = TagApi.fromJSON(tag: tags).sorted(by: { $0.name.lowercased() < $1.name.lowercased() })
self.isRefreshingTags = false self.isRefreshingTags = false
self.isInitiallyRefreshingTags = false
if let success = onSuccess { if let success = onSuccess {
Logger.sys.debug("successfully refreshed tags") Logger.sys.debug("successfully refreshed tags")

View File

@ -17,53 +17,62 @@ struct AppSkeleton: View {
@State private var selection = 0 // Tab view selection @State private var selection = 0 // Tab view selection
var body: some View { var body: some View {
TabView {
PlaylistList() if self.liveUser.isInitiallyRefreshingUser
.tabItem { || self.liveUser.isInitiallyRefreshingPlaylists
VStack { || self.liveUser.isInitiallyRefreshingTags
Image(systemName: "music.note.list") {
Text("Playlists") LoadingScreen()
} .onAppear {
self.fetchAll()
} }
.tag(0) } else {
if liveUser.lastfm_connected() { TabView {
TagList() PlaylistList()
.tabItem { .tabItem {
VStack { VStack {
Image(systemName: "tag") Image(systemName: "music.note.list")
Text("Tags") Text("Playlists")
} }
} }
.tag(1) .tag(0)
}
if let user = liveUser.user { if liveUser.lastfm_connected() {
if user.type == .admin {
AdminList() TagList()
.tabItem( { .tabItem {
VStack { VStack {
Image(systemName: "person.badge.key.fill") Image(systemName: "tag")
Text("Admin") Text("Tags")
} }
}) }
.tag(2) .tag(1)
} }
}
SettingsList() if let user = liveUser.user {
.tabItem { if user.type == .admin {
VStack { AdminList()
Image(systemName: "slider.horizontal.3") .tabItem( {
Text("Settings") VStack {
Image(systemName: "person.badge.key.fill")
Text("Admin")
}
})
.tag(2)
} }
} }
.tag(3)
}.onAppear { SettingsList()
self.fetchAll() .tabItem {
VStack {
Image(systemName: "slider.horizontal.3")
Text("Settings")
}
}
.tag(3)
}
} }
} }

View File

@ -0,0 +1,38 @@
//
// LoadingScreen.swift
// Mixonomer
//
// Created by Andy Pack on 10/12/2022.
// Copyright © 2022 Sarsoo. All rights reserved.
//
import SwiftUI
struct LoadingScreen: View {
var frameSize: CGFloat = 144
@State private var isAnimating = false
var body: some View {
Image("Splash")
// framing
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: frameSize)
// animation
.rotationEffect(Angle(degrees: isAnimating ? 360.0 : 0.0))
.animation(
// .easeInOut(duration: 1)
.spring(response: 0.7, dampingFraction: 0.8, blendDuration: 0)
.repeatForever(autoreverses: false), value: isAnimating)
.onAppear {
isAnimating = true
}
}
}
struct LoadingScreen_Previews: PreviewProvider {
static var previews: some View {
LoadingScreen()
}
}