Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚧 macOS / Linux Application #10

Draft
wants to merge 10 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/Windows-GUI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: microsoft/[email protected]

- name: Setup NuGet
uses: NuGet/setup-nuget@v1.0.6
uses: NuGet/setup-nuget@latest

- name: Restore dependencies
run: nuget restore CheckIP.Windows\CheckIP.sln
Expand Down
59 changes: 59 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ MigrationBackup/
*.keystore
*.pw

# Rider
.idea/

### macOS ###
# General
.DS_Store
Expand Down Expand Up @@ -386,3 +389,59 @@ Temporary Items
# iCloud generated files
*.icloud
CheckIP.Windows/Setup/Output/


### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

### Xcode ###
## User settings
xcuserdata/

## Xcode 8 and earlier
*.xcscmblueprint
*.xccheckout

### Xcode Patch ###
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcodeproj/project.xcworkspace/
!*.xcworkspace/contents.xcworkspacedata
/*.gcno
**/xcshareddata/WorkspaceSettings.xcsettings

## Avalonia Build Output
CheckIP.Avalonia/Output/*
CheckIP.Avalonia/macOS.Sign/App
*.pkg
14 changes: 14 additions & 0 deletions CheckIP.Avalonia/CheckIP.Avalonia/App.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:styling="clr-namespace:FluentAvalonia.Styling;assembly=FluentAvalonia"
x:Class="CheckIP.App"
Name="CheckIP">
<Application.Styles>
<styling:FluentAvaloniaTheme />
</Application.Styles>
<NativeMenu.Menu>
<NativeMenu>
<NativeMenuItem Header="About CheckIP" Click="NativeMenuItem_OnClick" />
</NativeMenu>
</NativeMenu.Menu>
</Application>
42 changes: 42 additions & 0 deletions CheckIP.Avalonia/CheckIP.Avalonia/App.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using CheckIP.Pages;

namespace CheckIP
{
public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}

public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new Main();
}

base.OnFrameworkInitializationCompleted();
}

private void NativeMenuItem_OnClick(object? sender, EventArgs e)
{
var window = new Window()
{
Title = "About CheckIP",
Content = new About(),
MaxHeight = 500,
MaxWidth = 400,
MinHeight = 500,
MinWidth = 400,
CanResize = false
};
window.Show();
}
}
}
1 change: 1 addition & 0 deletions CheckIP.Avalonia/CheckIP.Avalonia/Assets/Logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 69 additions & 0 deletions CheckIP.Avalonia/CheckIP.Avalonia/CheckIP.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>CheckIP.ico</ApplicationIcon>
<ProductName>CheckIP</ProductName>
<Authors>valnoxy</Authors>
<Company>Exploitox</Company>
<Description>Get more information about an IP address.</Description>
<Copyright>Copyright © 2018 - 2023 Exploitox. All rights reserved.</Copyright>
<RepositoryUrl>https://github.com/valnoxy/checkip</RepositoryUrl>
<Version>1.0.0-preview1</Version>
<RuntimeIdentifiers>osx-x64;osx-arm64;linux-x64;linux-arm64</RuntimeIdentifiers>

<CFBundleName>CheckIP</CFBundleName> <!-- Also defines .app file name -->
<CFBundleDisplayName>CheckIP</CFBundleDisplayName>
<CFBundleIdentifier>dev.valnoxy.checkip</CFBundleIdentifier>
<CFBundleVersion>1.0.0-preview1</CFBundleVersion>
<CFBundlePackageType>APPL</CFBundlePackageType>
<CFBundleSignature>????</CFBundleSignature>
<CFBundleExecutable>CheckIP</CFBundleExecutable>
<CFBundleIconFile>CheckIP.icns</CFBundleIconFile> <!-- Will be copied from output directory -->
<NSPrincipalClass>NSApplication</NSPrincipalClass>
<NSHighResolutionCapable>true</NSHighResolutionCapable>
<CFBundleShortVersionString>1.0.0-preview1</CFBundleShortVersionString>
<UseAppHost>true</UseAppHost>
<RootNamespace>CheckIP</RootNamespace>
</PropertyGroup>

<ItemGroup>
<None Remove="Assets\Logo.svg" />
<None Update="CheckIP.icns">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<TrimmerRootDescriptor Include="Roots.xml" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.0-preview5" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview5" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview5" />
<PackageReference Include="Avalonia.Svg.Skia" Version="11.0.0-preview5" />
<PackageReference Include="FluentAvaloniaUI" Version="2.0.0-preview5" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="XamlNameReferenceGenerator" Version="1.6.1" />
<PackageReference Include="Dotnet.Bundle" Version="*" />
</ItemGroup>

<ItemGroup>
<AvaloniaResource Include="Assets\Logo.svg" />
</ItemGroup>

<ItemGroup>
<Compile Update="Main.axaml.cs">
<DependentUpon>Main.axaml</DependentUpon>
</Compile>
<Compile Update="Pages\About.axaml.cs">
<DependentUpon>About.axaml</DependentUpon>
</Compile>
</ItemGroup>

</Project>
Binary file added CheckIP.Avalonia/CheckIP.Avalonia/CheckIP.icns
Binary file not shown.
Binary file added CheckIP.Avalonia/CheckIP.Avalonia/CheckIP.ico
Binary file not shown.
33 changes: 33 additions & 0 deletions CheckIP.Avalonia/CheckIP.Avalonia/Main.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="using:FluentAvalonia.UI.Controls"
mc:Ignorable="d"
MaxHeight="615" MaxWidth="512"
MinHeight="615" MinWidth="512"
CanResize="False"
x:Class="CheckIP.Main"
WindowStartupLocation="CenterScreen"
Title="CheckIP">

<Grid RowDefinitions="Auto,*">
<Grid Grid.Row="1" Margin="0">
<ui:NavigationView
x:Name="RootNavigation"
PaneDisplayMode="LeftCompact"
AlwaysShowHeader="False"
IsSettingsVisible="False"
Margin="6,0,6,0"/>
</Grid>

<Label x:Name="DebugLabel"
Grid.Row="0"
Content=""
IsVisible="False"
VerticalAlignment="Top"
HorizontalAlignment="Center"
Foreground="Red"
FontSize="13"/>
</Grid>
</Window>
63 changes: 63 additions & 0 deletions CheckIP.Avalonia/CheckIP.Avalonia/Main.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using Avalonia.Controls;
using FluentAvalonia.Core;
using FluentAvalonia.UI.Controls;
using System;
using System.Collections.Generic;

namespace CheckIP
{
public partial class Main : Window
{
public NavigationView? NavView;
public static Main Instance { get; private set; }

public Main()
{
InitializeComponent();
Instance = this;
#if DEBUG
DebugLabel.Content = "Avalonia Debug build - This is not a production ready build.";
DebugLabel.IsVisible = true;
#endif

// Build the navigation menu
NavView = this.FindControl<NavigationView>("RootNavigation");

var navItems = new List<NavigationViewItemBase>();
var footerNavItems = new List<NavigationViewItemBase>();
navItems.Add(new NavigationViewItem
{
Content = "Fetch",
IconSource = new SymbolIconSource { Symbol = Symbol.Globe },
Tag = "FetchIP"
});
navItems.Add(new NavigationViewItem
{
Content = "My IP",
IconSource = new SymbolIconSource { Symbol = Symbol.MapPin },
Tag = "MyIP"
});

footerNavItems.Add(new NavigationViewItem
{
Content = "About",
IconSource = new SymbolIconSource { Symbol = Symbol.ContactInfo },
Tag = "About"
});

NavView!.MenuItems = navItems;
NavView!.FooterMenuItems = footerNavItems;

NavView!.SelectionChanged += NavigationViewChanged!;
NavView.SelectedItem = NavView.MenuItems.ElementAt(0);
}

private void NavigationViewChanged(object sender, NavigationViewSelectionChangedEventArgs e)
{
if (e.SelectedItem is not NavigationViewItem nvi) return;
var smpPage = $"CheckIP.Pages.{nvi.Tag}";
var pg = Activator.CreateInstance(Type.GetType(smpPage)!);
(sender as NavigationView)!.Content = pg;
}
}
}
66 changes: 66 additions & 0 deletions CheckIP.Avalonia/CheckIP.Avalonia/Pages/About.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="CheckIP.Pages.About">
<StackPanel Margin="20">
<Label Content="About" HorizontalAlignment="Left" Margin="-6,0,0,30" VerticalAlignment="Top" FontSize="25"/>
<Image x:Name="LogoImg" Source="{SvgImage avares://CheckIP/Assets/Logo.svg}" Height="40" Margin="0,0,0,30"/>
<StackPanel Spacing="5">
<Label x:Name="LabelTitle"
Content="About this App"
FontSize="15"
Margin="-4,0,0,0"
FontWeight="Bold"/>

<Label x:Name="ValueVersion"
Content="CheckIP"
Margin="-4,0,0,0"
FontSize="15"/>

<Label x:Name="ValueCopyright"
Content="Copyright © Exploitox. All rights reserved."
Margin="-4,-10,0,0"
FontSize="15"/>

<Label x:Name="AvaloniaVersion"
Content="Avalonia"
Margin="-4,0,0,0"
FontSize="15"/>

<Label x:Name="FluentAvaloniaVersion"
Content="FluentAvalonia"
Margin="-4,-10,0,0"
FontSize="15"/>

<Label x:Name="NewtonsoftVersion"
Content="Newtonsoft.Json"
Margin="-4,-10,0,0"
FontSize="15"/>

<TextBlock x:Name="LicenseText" VerticalAlignment="Top" FontSize="15" TextWrapping="WrapWithOverflow" Height="100">
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
</TextBlock>

</StackPanel>
<StackPanel Spacing="5">
<ui:HyperlinkButton
Content="Source Code on GitHub"
NavigateUri="https://github.com/valnoxy/checkip"
FontSize="15" />
<ui:HyperlinkButton
Content="Homepage"
NavigateUri="https://exploitox.de"
FontSize="15" />
<ui:HyperlinkButton
Content="GNU General Public License"
NavigateUri="https://exploitox.de/license/checkip"
FontSize="15" />
</StackPanel>
</StackPanel>
</UserControl>
Loading