Skip to content

Commit

Permalink
Add toast for pinning/removing charts
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunkomath committed Oct 30, 2022
1 parent a3d958f commit e8abed8
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 15 deletions.
33 changes: 25 additions & 8 deletions netdata.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
55D3076F24D18F9600CF076B /* UserDefaults+Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55D3076E24D18F9600CF076B /* UserDefaults+Color.swift */; };
55D3077224D197A600CF076B /* AlarmsListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55D3077124D197A600CF076B /* AlarmsListView.swift */; };
55D3077424D19D1E00CF076B /* AlarmListRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55D3077324D19D1E00CF076B /* AlarmListRow.swift */; };
55D82951290E2032009569BD /* AlertToast in Frameworks */ = {isa = PBXBuildFile; productRef = 55D82950290E2032009569BD /* AlertToast */; };
55E91EBD24D99D6900218F57 /* WelcomeScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E91EBC24D99D6900218F57 /* WelcomeScreen.swift */; };
55EE682A24CD962100546B1A /* UserSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55EE682924CD962100546B1A /* UserSettings.swift */; };
55FC8F6B24BAD8F100CA8751 /* ServerDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55FC8F6A24BAD8F100CA8751 /* ServerDetailView.swift */; };
Expand Down Expand Up @@ -201,6 +202,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
55D82951290E2032009569BD /* AlertToast in Frameworks */,
552715552622EB2A00A57510 /* Bugsnag in Frameworks */,
55D1C53824B969AC0087F8A2 /* CloudKit.framework in Frameworks */,
);
Expand Down Expand Up @@ -521,6 +523,7 @@
name = netdata;
packageProductDependencies = (
552715542622EB2A00A57510 /* Bugsnag */,
55D82950290E2032009569BD /* AlertToast */,
);
productName = netdata;
productReference = 55D1C4FE24B95E6D0087F8A2 /* netdata.app */;
Expand Down Expand Up @@ -598,6 +601,7 @@
mainGroup = 55D1C4F524B95E6D0087F8A2;
packageReferences = (
552715532622EB2A00A57510 /* XCRemoteSwiftPackageReference "bugsnag-cocoa" */,
55D8294F290E2032009569BD /* XCRemoteSwiftPackageReference "AlertToast" */,
);
productRefGroup = 55D1C4FF24B95E6D0087F8A2 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -757,7 +761,7 @@
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
CODE_SIGN_ENTITLEMENTS = AlarmWidgetExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 48;
CURRENT_PROJECT_VERSION = 49;
DEVELOPMENT_TEAM = H78GYE72WQ;
INFOPLIST_FILE = AlarmWidget/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
Expand All @@ -766,7 +770,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.11.7;
MARKETING_VERSION = 1.11.8;
PRODUCT_BUNDLE_IDENTIFIER = com.techulus.netdata.AlarmWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -784,7 +788,7 @@
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
CODE_SIGN_ENTITLEMENTS = AlarmWidgetExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 48;
CURRENT_PROJECT_VERSION = 49;
DEVELOPMENT_TEAM = H78GYE72WQ;
INFOPLIST_FILE = AlarmWidget/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
Expand All @@ -793,7 +797,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.11.7;
MARKETING_VERSION = 1.11.8;
PRODUCT_BUNDLE_IDENTIFIER = com.techulus.netdata.AlarmWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -928,7 +932,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = netdata/netdata.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 48;
CURRENT_PROJECT_VERSION = 49;
DEVELOPMENT_ASSET_PATHS = "\"netdata/Preview Content\"";
DEVELOPMENT_TEAM = H78GYE72WQ;
ENABLE_PREVIEWS = YES;
Expand All @@ -938,7 +942,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.11.7;
MARKETING_VERSION = 1.11.8;
PRODUCT_BUNDLE_IDENTIFIER = com.techulus.netdata;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;
Expand All @@ -956,7 +960,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = netdata/netdata.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 48;
CURRENT_PROJECT_VERSION = 49;
DEVELOPMENT_ASSET_PATHS = "\"netdata/Preview Content\"";
DEVELOPMENT_TEAM = H78GYE72WQ;
ENABLE_PREVIEWS = YES;
Expand All @@ -966,7 +970,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.11.7;
MARKETING_VERSION = 1.11.8;
PRODUCT_BUNDLE_IDENTIFIER = com.techulus.netdata;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;
Expand Down Expand Up @@ -1119,6 +1123,14 @@
minimumVersion = 6.8.3;
};
};
55D8294F290E2032009569BD /* XCRemoteSwiftPackageReference "AlertToast" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/elai950/AlertToast.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.0.0;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand All @@ -1127,6 +1139,11 @@
package = 552715532622EB2A00A57510 /* XCRemoteSwiftPackageReference "bugsnag-cocoa" */;
productName = Bugsnag;
};
55D82950290E2032009569BD /* AlertToast */ = {
isa = XCSwiftPackageProductDependency;
package = 55D8294F290E2032009569BD /* XCRemoteSwiftPackageReference "AlertToast" */;
productName = AlertToast;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 55D1C4F624B95E6D0087F8A2 /* Project object */;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"pins" : [
{
"identity" : "alerttoast",
"kind" : "remoteSourceControl",
"location" : "https://github.com/elai950/AlertToast.git",
"state" : {
"revision" : "a4f4267f6454259ba4ed8f9dadb87334a789c26c",
"version" : "1.3.7"
}
},
{
"identity" : "bugsnag-cocoa",
"kind" : "remoteSourceControl",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import SwiftUI
import AlertToast

struct CustomChartDetailView: View {
var serverChart: ServerChart
Expand All @@ -15,6 +16,9 @@ struct CustomChartDetailView: View {
@State private var chartData = ServerData(labels: [], data: [])
@State private var isLive = false

@State private var showAddedToast = false
@State private var showRemovedToast = false

@ObservedObject var userSettings = UserSettings()

let timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect()
Expand All @@ -32,19 +36,17 @@ struct CustomChartDetailView: View {

if userSettings.bookmarks.contains(serverChart.id) {
Button(action: {
withAnimation {
userSettings.bookmarks = userSettings.bookmarks.filter { $0 != serverChart.id }
}
userSettings.bookmarks = userSettings.bookmarks.filter { $0 != serverChart.id }
showRemovedToast.toggle()
}, label: {
Label("Remove pin", systemImage: "pin")
})
.readableGuidePadding()
} else {
Button(action: {
withAnimation {
// Fix warning https://developer.apple.com/forums/thread/711899
userSettings.bookmarks.insert(serverChart.id, at: 0)
}
// Fix warning https://developer.apple.com/forums/thread/711899
userSettings.bookmarks.insert(serverChart.id, at: 0)
showAddedToast.toggle()
}, label: {
Label("Pin chart", systemImage: "pin.fill")
})
Expand All @@ -71,6 +73,12 @@ struct CustomChartDetailView: View {
PulsatingView(live: isLive)
}
}
.toast(isPresenting: $showAddedToast) {
AlertToast(displayMode: .banner(.pop), type: .complete(.green), title: "Chart Added")
}
.toast(isPresenting: $showRemovedToast) {
AlertToast(displayMode: .banner(.pop), type: .complete(.green), title: "Chart Removed")
}
}

func units() -> String {
Expand Down

0 comments on commit e8abed8

Please sign in to comment.