Why does the MacMenuBarExtra label only work for sf symbol images and text? - swift

I'm using a MacMenuBarExtra for my macOS app, however, I can't seem to make any view that's not a sf symbol image or text render properly. Here is the code I am using in my app file and if you run it, you'll see that no icon shows in the menu bar. I want to create a dynamic icon which will show up there, does anyone have any idea why this is happening?
MenuBarExtra {
ContentView()
} label: {
Circle().foregroundColor(.green)
}
.menuBarExtraStyle(.window)

Related

How to change the image of my java app icon

I have searched for an answer to this question in many places, but none of the answers satisfies what I really want. There are variations of the solution, but they all go along the lines of the code I have below:
MainFrame() {
ImageIcon logo = new ImageIcon(getClass().getResource("file_path"));
setIconImage(logo.getImage);
//the rest of my code
}
public static void main(String[] args){
MainFrame mf = new MainFrame();
mf.pack();
mf.setVisible(true);
}
Basically, load an image or an image icon from a file, and then call the setIconImage() method from the JFrame. This sets the icon image in the title bar of the window, and also the icon image in the task bar when the app is active. But it does not set the icon image of the app icon. In order to show you more clearly what I mean, please see the image I attached, where I circled the three icons. The one with the Java coffee cup is the one I haven't been able to change.
the taskbar, my app, and the window of my app
Can somebody help me set the image of the app icon itself (not just the task bar and title bar icons)?
I was not able change the image of the jar file itself as it sits inside a directory, as shown in the image attached to my question. However, I was able was to set the icon image of the .exe file when I packaged it with jpackage.
Basically, once I was ready to package my app I entered in Command Prompt, making sure to include the --icon option:
jpackage --input C:\app_files\MyApp --name MyApp --main-jar myapp.jar --main-class main.MainThread --icon C:\app_files\MyApp\logo.ico --win-shortcut --dest C:\Users\Desktop\Apps --runtime-image C:\app_files\my_jre
Note: Here, at least for Windows 10, the icon image must be an .ico file.

How do I make an image show on the namecard on playgrounds

enter image description here
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
Image("MyImage")
.resizable()
.scaledToFit()
Text("I am Jia Ying")
}
}
}
I am creating a name card for an app project. I typed in the above code, selected a photo from the photo gallery as the app icon and ran the app. I was successful once, however as I tried it again, only the words showed up. I looked at the image asset and found it was horizontal (the initial photo was vertical). Could the horizontal image asset be related to the bug? Can anyone suggest a solution to fix the problem? I greatly appreciate it!

White status bar with "App Scene WindowGroup"

With the new App Scene WindowGroup structure in Xcode 12, how can you specify the white status bar? I've searched around but so far have not been able to find an answer.
#main
struct MyApp: App {
var body: some Scene {
WindowGroup {
AppView()
}
}
}
Answered in the Apple Developer Forum: https://developer.apple.com/forums/thread/658539
Open your project in Xcode. form the left navigator(it is usually open, but if its not, you can open it by (command + 0) ) select Your_Project_Name.xcodeporj file (usually the first file, with a mainly blue foreground with appstore icon on it). select your ios-macos target from the targets (or any other targets which do have an status bar to configure). make sure youre on the general tab. one of the section should be Development Info which includes a status bar part. configure the status bar there.

Custom Icon for Gnome Shell Extension in Top Panel not visible

I try to use a custom SVG for my GNOME shell extension as status icon in top panel. But the custom icon is never shown, just the widget's label text. And I find no error in log output.
When I try to set a build-in icon like "system-search-symbolic" it works, this icon is shown.
This is my code snippet (the SVG is in an "icons" directory of my extension: /home/myusername/.local/share/gnome-shell/extensions/my-widget#my-widgets/icons/timeclock-16x16.svg):
// ...
let widgetBoxLayout = new St.BoxLayout();
let iconPath = `${Me.path}/icons/timeclock-16x16.svg`;
// just for debug if path is correct
log(`${Me.metadata.name}: Icon path=${iconPath}`);
let gicon = Gio.icon_new_for_string(`${iconPath}`);
let icon = new St.Icon({ gicon: gicon, style_class: 'system-status-icon', icon_size: 16 });
// this works for build-in icon:
//let icon = new St.Icon({ icon_name: 'system-search-symbolic', style_class: 'system-status-icon'});
widgetBoxLayout.add(icon);
widgetBoxLayout.add(this.widgetText);
//...
Maybe it's a problem that there is an "#" char in icon path?
But why no error is logged?
What is the correct code to use a custom icon for status panel?
(I have GNOME Shell 3.30.2)
Oh no! This one of these "fight for weeks alone, finally ask the crowd, suddenly know the solution yourself" cases ...
The icon was actually visible but since I use a dark theme and the icon itself is also dark it was not "visible". I inverted the colors of this icon and now I can see the icon next to my text in top panel.
Now I have to find out which icon to use depending on user's theme, but the original issue is solved.
Maybe this answer helps other developer making same stupid error.
You need to use -symbolic icons to allow automatic theme aware re-colorization of the icons. Just change the file name of the icon to timeclock-symbolic.svg, at least this should be your first step if every other aspect is fine.

Swift pages: Load remote image

I'm trying to load a remote image with the following code:
//: ![Xcode icon](http://devimages.apple.com.edgekey.net/assets/elements/icons/128x128/xcode.png "Some hover text")
But when I switch to "Show rendered markup" I only see the "Xcode icon" text.
Any of you knows why the swift pages are not showing the image? or what do I need to do for the swift pages to show the images?
I'll really appreciate your help.
I believe playgrounds will not load remote image for you, only quickhelp using that format will..
To load an image download png you want to show, add it to your playground resources and load using:
//: ![Xcode icon](xcode.png)