From 8a2434316c8d16528099ed773b5dbe7ad4699483 Mon Sep 17 00:00:00 2001 From: lumaa-dev Date: Mon, 11 Nov 2024 15:28:47 +0100 Subject: [PATCH] Open Bubble control button --- Bubble.xcodeproj/project.pbxproj | 6 + .../Hero/hero.pen.symbolset/Bbl_Pen-3.svg | 107 ++++++++++++++++++ .../Hero/hero.pen.symbolset/Contents.json | 16 +++ Bubble/Localizable.xcstrings | 39 +++++++ BubbleWidgets/AppIntent.swift | 16 +++ .../hero.pen.symbolset/Bbl_Pen-3.svg | 107 ++++++++++++++++++ .../hero.pen.symbolset/Contents.json | 15 +++ BubbleWidgets/BubbleWidgetsBundle.swift | 1 + BubbleWidgets/CreatePostWidget.swift | 20 ++-- BubbleWidgets/FollowGoalWidget.swift | 44 ++++++- BubbleWidgets/OpenAppControl.swift | 22 ++++ 11 files changed, 379 insertions(+), 14 deletions(-) create mode 100644 Bubble/Assets.xcassets/Hero/hero.pen.symbolset/Bbl_Pen-3.svg create mode 100644 Bubble/Assets.xcassets/Hero/hero.pen.symbolset/Contents.json create mode 100644 BubbleWidgets/Assets.xcassets/hero.pen.symbolset/Bbl_Pen-3.svg create mode 100644 BubbleWidgets/Assets.xcassets/hero.pen.symbolset/Contents.json create mode 100644 BubbleWidgets/OpenAppControl.swift diff --git a/Bubble.xcodeproj/project.pbxproj b/Bubble.xcodeproj/project.pbxproj index 5137714..88984f8 100644 --- a/Bubble.xcodeproj/project.pbxproj +++ b/Bubble.xcodeproj/project.pbxproj @@ -226,6 +226,8 @@ B9FB94BC2B2F035500D81C07 /* Tag.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9FB94BB2B2F035500D81C07 /* Tag.swift */; }; B9FD18982C55108F00A74A71 /* EditProfileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9FD18972C55108F00A74A71 /* EditProfileView.swift */; }; B9FD189A2C57DE9200A74A71 /* IconView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9FD18992C57DE9200A74A71 /* IconView.swift */; }; + B9FE4B502CE241DE00CE1E53 /* OpenAppControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9FE4B4F2CE241DE00CE1E53 /* OpenAppControl.swift */; }; + B9FE4B512CE241DE00CE1E53 /* OpenAppControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9FE4B4F2CE241DE00CE1E53 /* OpenAppControl.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -388,6 +390,7 @@ B9FB94BB2B2F035500D81C07 /* Tag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tag.swift; sourceTree = ""; }; B9FD18972C55108F00A74A71 /* EditProfileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditProfileView.swift; sourceTree = ""; }; B9FD18992C57DE9200A74A71 /* IconView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconView.swift; sourceTree = ""; }; + B9FE4B4F2CE241DE00CE1E53 /* OpenAppControl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenAppControl.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -481,6 +484,7 @@ B9B469AF2B9A275F00AD5585 /* FollowGoalWidget.swift */, B9A80DDD2C67BFF800DE3D88 /* CreatePostWidget.swift */, B98DD8D72C6821F7009F40DD /* CreatePostControl.swift */, + B9FE4B4F2CE241DE00CE1E53 /* OpenAppControl.swift */, B9C20D132B921C78004DC9B3 /* AppIntent.swift */, B9C20D152B921C7B004DC9B3 /* Assets.xcassets */, B9C20D172B921C7B004DC9B3 /* Info.plist */, @@ -979,6 +983,7 @@ B9A80DE72C67C3FC00DE3D88 /* Account+Elms.swift in Sources */, B9A80DE82C67C3FC00DE3D88 /* Account.swift in Sources */, B9A80DE92C67C3FC00DE3D88 /* LoggedAccounts.swift in Sources */, + B9FE4B502CE241DE00CE1E53 /* OpenAppControl.swift in Sources */, B9A80DEA2C67C3FC00DE3D88 /* AccountManager.swift in Sources */, B9CDE7AF2C9FFCFA004B1BDD /* SheetBackground.swift in Sources */, B9A80DEB2C67C3FC00DE3D88 /* AccountsList.swift in Sources */, @@ -1022,6 +1027,7 @@ B9FB949B2B2EF09A00D81C07 /* Client.swift in Sources */, B9FB949D2B2EF0D600D81C07 /* Instance.swift in Sources */, B93ADFCB2B7625CD00FF9172 /* DiscoveryView.swift in Sources */, + B9FE4B512CE241DE00CE1E53 /* OpenAppControl.swift in Sources */, B9D9C6C72B6A590F00C26A41 /* ProfilePicture.swift in Sources */, B9842C102B2F228C00D9F3C1 /* Status.swift in Sources */, B9CDE7B02C9FFCFA004B1BDD /* SheetBackground.swift in Sources */, diff --git a/Bubble/Assets.xcassets/Hero/hero.pen.symbolset/Bbl_Pen-3.svg b/Bubble/Assets.xcassets/Hero/hero.pen.symbolset/Bbl_Pen-3.svg new file mode 100644 index 0000000..cd5a602 --- /dev/null +++ b/Bubble/Assets.xcassets/Hero/hero.pen.symbolset/Bbl_Pen-3.svg @@ -0,0 +1,107 @@ + + + + + + + Weight/Scale Variations + Ultralight + Thin + Light + Regular + Medium + Semibold + Bold + Heavy + Black + + + + + + + + + + + Design Variations + Symbols are supported in up to nine weights and three scales. + For optimal layout with text and other symbols, vertically align + symbols with the adjacent text. + + + + + + Margins + Leading and trailing margins on the left and right side of each symbol + can be adjusted by modifying the x-location of the margin guidelines. + Modifications are automatically applied proportionally to all + scales and weights. + + + + Exporting + Symbols should be outlined when exporting to ensure the + design is preserved when submitting to Xcode. + Template v.5.0 + Requires Xcode 15 or greater + Generated from circle + Typeset at 100.0 points + Small + Medium + Large + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Bubble/Assets.xcassets/Hero/hero.pen.symbolset/Contents.json b/Bubble/Assets.xcassets/Hero/hero.pen.symbolset/Contents.json new file mode 100644 index 0000000..f49c3aa --- /dev/null +++ b/Bubble/Assets.xcassets/Hero/hero.pen.symbolset/Contents.json @@ -0,0 +1,16 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "localizable" : true, + "symbol-rendering-intent" : "template" + }, + "symbols" : [ + { + "filename" : "Bbl_Pen-3.svg", + "idiom" : "universal" + } + ] +} diff --git a/Bubble/Localizable.xcstrings b/Bubble/Localizable.xcstrings index 93e70ea..fdb6cb3 100644 --- a/Bubble/Localizable.xcstrings +++ b/Bubble/Localizable.xcstrings @@ -1254,6 +1254,38 @@ } } }, + "control.open.app" : { + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Open Bubble" + } + }, + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Ouvrir Bubble" + } + } + } + }, + "control.open.app.description" : { + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Opens Bubble" + } + }, + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Ouvre Bubble" + } + } + } + }, "control.open.composer" : { "localizations" : { "en" : { @@ -1784,6 +1816,12 @@ } } } + }, + "intent.open.app" : { + + }, + "intent.open.app.description" : { + }, "intent.open.composer" : { "localizations" : { @@ -5152,6 +5190,7 @@ } }, "widget.composer" : { + "extractionState" : "stale", "localizations" : { "en" : { "stringUnit" : { diff --git a/BubbleWidgets/AppIntent.swift b/BubbleWidgets/AppIntent.swift index 8a0eaaa..162db5e 100644 --- a/BubbleWidgets/AppIntent.swift +++ b/BubbleWidgets/AppIntent.swift @@ -143,6 +143,22 @@ extension Visibility: AppEnum { } } +struct OpenAppIntent: AppIntent { + static var title: LocalizedStringResource = "intent.open.app" + static var description: IntentDescription? = IntentDescription("intent.open.app.description") + + static var isDiscoverable: Bool = true + static var openAppWhenRun: Bool = true + + static var authenticationPolicy: IntentAuthenticationPolicy = .requiresLocalDeviceAuthentication + + func perform() async throws -> some IntentResult { + UniversalNavigator.static.selectedTab = .timeline + UniversalNavigator.static.presentedSheet = nil + return .result() + } +} + struct OpenComposerIntent: AppIntent { static var title: LocalizedStringResource = "intent.open.composer" static var description: IntentDescription? = IntentDescription("intent.open.composer.description") diff --git a/BubbleWidgets/Assets.xcassets/hero.pen.symbolset/Bbl_Pen-3.svg b/BubbleWidgets/Assets.xcassets/hero.pen.symbolset/Bbl_Pen-3.svg new file mode 100644 index 0000000..cd5a602 --- /dev/null +++ b/BubbleWidgets/Assets.xcassets/hero.pen.symbolset/Bbl_Pen-3.svg @@ -0,0 +1,107 @@ + + + + + + + Weight/Scale Variations + Ultralight + Thin + Light + Regular + Medium + Semibold + Bold + Heavy + Black + + + + + + + + + + + Design Variations + Symbols are supported in up to nine weights and three scales. + For optimal layout with text and other symbols, vertically align + symbols with the adjacent text. + + + + + + Margins + Leading and trailing margins on the left and right side of each symbol + can be adjusted by modifying the x-location of the margin guidelines. + Modifications are automatically applied proportionally to all + scales and weights. + + + + Exporting + Symbols should be outlined when exporting to ensure the + design is preserved when submitting to Xcode. + Template v.5.0 + Requires Xcode 15 or greater + Generated from circle + Typeset at 100.0 points + Small + Medium + Large + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BubbleWidgets/Assets.xcassets/hero.pen.symbolset/Contents.json b/BubbleWidgets/Assets.xcassets/hero.pen.symbolset/Contents.json new file mode 100644 index 0000000..b823e85 --- /dev/null +++ b/BubbleWidgets/Assets.xcassets/hero.pen.symbolset/Contents.json @@ -0,0 +1,15 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "symbol-rendering-intent" : "template" + }, + "symbols" : [ + { + "filename" : "Bbl_Pen-3.svg", + "idiom" : "universal" + } + ] +} diff --git a/BubbleWidgets/BubbleWidgetsBundle.swift b/BubbleWidgets/BubbleWidgetsBundle.swift index 49740b9..43444b9 100644 --- a/BubbleWidgets/BubbleWidgetsBundle.swift +++ b/BubbleWidgets/BubbleWidgetsBundle.swift @@ -22,6 +22,7 @@ struct BubbleWidgetsBundle: WidgetBundle { CreatePostWidget() // iOS 18 + OpenAppControl() CreatePostControl() } diff --git a/BubbleWidgets/CreatePostWidget.swift b/BubbleWidgets/CreatePostWidget.swift index 6f3d51d..f80593e 100644 --- a/BubbleWidgets/CreatePostWidget.swift +++ b/BubbleWidgets/CreatePostWidget.swift @@ -29,18 +29,16 @@ struct CreatePostWidget: Widget { var body: some View { ZStack { if family == .systemSmall { - VStack { - Button(intent: OpenComposerIntent()) { - Image(systemName: "square.and.pencil") - .resizable() - .scaledToFit() - .frame(width: 80, height: 80) - } - .buttonStyle(.plain) - - Text("widget.composer") - .font(.caption) + Button(intent: OpenComposerIntent()) { + Text("status.posting.placeholder") + .foregroundStyle(Color.gray) + .font(.callout) + .frame(width: 110, height: 110, alignment: .topLeading) + .padding(9.0) + .background(Color.gray.opacity(0.3)) + .clipShape(RoundedRectangle(cornerRadius: 20)) } + .buttonStyle(.plain) } } .containerBackground(Color.appBackground, for: .widget) diff --git a/BubbleWidgets/FollowGoalWidget.swift b/BubbleWidgets/FollowGoalWidget.swift index 52bc7b9..71d1768 100644 --- a/BubbleWidgets/FollowGoalWidget.swift +++ b/BubbleWidgets/FollowGoalWidget.swift @@ -16,7 +16,9 @@ struct FollowGoalWidgetView: View { if let account = entry.configuration.account { ZStack { #if os(iOS) - if family == WidgetFamily.systemMedium { + if family == WidgetFamily.systemSmall { + small + } else if family == WidgetFamily.systemMedium { medium } #endif @@ -33,7 +35,43 @@ struct FollowGoalWidgetView: View { .font(.caption) } } - + + var small: some View { + VStack { + HStack(alignment: .center, spacing: 7.5) { + Image(uiImage: entry.pfp) + .resizable() + .scaledToFit() + .frame(width: 30, height: 30) + .foregroundStyle(Color.white) + .clipShape(Circle()) + + Text("@\(entry.configuration.account!.username)") + .redacted(reason: .privacy) + .font(.caption.bold()) + .lineLimit(1) + } + .padding(.vertical, 4.5) + + Gauge(value: Double(entry.followers), in: 0...maxGauge) { + EmptyView() + } currentValueLabel: { + Text(entry.followers, format: .number.notation(.compactName)) + .multilineTextAlignment(.center) + .redacted(reason: .privacy) + } minimumValueLabel: { + EmptyView() + } maximumValueLabel: { + EmptyView() + } + .gaugeStyle(.accessoryCircularCapacity) + .frame(width: 100, height: 100, alignment: .center) + .scaleEffect(1.5) + .padding(.bottom) + .tint(Double(entry.followers) >= maxGauge ? Color.green : Color.blue) + } + } + var medium: some View { VStack(alignment: .center) { HStack(alignment: .center, spacing: 7.5) { @@ -137,7 +175,7 @@ struct FollowGoalWidget: Widget { .configurationDisplayName("widget.follow-goal") .description("widget.follow-goal.description") #if os(iOS) - .supportedFamilies([.systemMedium, .accessoryRectangular, .accessoryCircular]) + .supportedFamilies([.systemSmall, .systemMedium, .accessoryRectangular, .accessoryCircular]) #else .supportedFamilies([.accessoryRectangular, .accessoryCircular]) #endif diff --git a/BubbleWidgets/OpenAppControl.swift b/BubbleWidgets/OpenAppControl.swift new file mode 100644 index 0000000..b737e3a --- /dev/null +++ b/BubbleWidgets/OpenAppControl.swift @@ -0,0 +1,22 @@ +// Made by Lumaa + + +// Made by Lumaa + +import SwiftUI +import WidgetKit + +@available(iOS 18.0, *) +struct OpenAppControl: ControlWidget { + let kind: String = "CreateAppControl" + + var body: some ControlWidgetConfiguration { + StaticControlConfiguration(kind: kind) { + ControlWidgetButton(action: OpenAppIntent()) { + Label("control.open.app", image: "hero.pen") + } + } + .displayName("control.open.app") + .description("control.open.app.description") + } +}