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

Avalonia (MacOS, Linux) port #85

Merged
merged 63 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
d61d9bc
First alpha commit
rocksdanister Sep 30, 2024
5228b20
MacOS native AppTitle
rocksdanister Oct 1, 2024
b2e3c0b
Fallback background control (Potato quality)
rocksdanister Oct 4, 2024
f0b3271
Titlebar input fix with ImageEx
rocksdanister Oct 4, 2024
b3efd29
Disable screensaver page when Potato quality
rocksdanister Oct 5, 2024
7651472
Fix background overlay brush not working
rocksdanister Oct 6, 2024
c834a5d
Add translation string Distance
rocksdanister Oct 6, 2024
1d8f2e4
Depth background creation using ml
rocksdanister Oct 6, 2024
ec81e7a
SystemInfoProvider handles SystemUtil fns
rocksdanister Oct 7, 2024
a82b6e0
File launcher service
rocksdanister Oct 7, 2024
3f89199
String resource loader abstraction
rocksdanister Oct 7, 2024
5451a20
Refactored ShaderUtil and disabled Clouds shader in avalonia..
rocksdanister Oct 8, 2024
95eca7f
Refactored UWP to match Avalonia
rocksdanister Oct 8, 2024
46330c0
Refactored weather unit listbox style..
rocksdanister Oct 8, 2024
65f2338
Removed unused converter
rocksdanister Oct 8, 2024
7b04773
App update checker
rocksdanister Oct 8, 2024
200d11a
Update notification
rocksdanister Oct 8, 2024
d98e329
Localized update available
rocksdanister Oct 9, 2024
7b6445b
Fixed ml model not being loaded in linux
rocksdanister Oct 9, 2024
ea2bf2f
Startup tasks and unhandled exception logging
rocksdanister Oct 9, 2024
9582093
Updater store last checked status
rocksdanister Oct 9, 2024
759f48d
Indicate Avalonia is running under quality perf setting
rocksdanister Oct 9, 2024
da8fb33
Updated accessibility icon
rocksdanister Oct 9, 2024
d7de6ca
Close depth dialog if no image selected and patches
rocksdanister Oct 9, 2024
a529ba6
NLog custom directory factory
rocksdanister Oct 9, 2024
2cc76ad
Moved common service impl to shared project
rocksdanister Oct 9, 2024
e687cec
Onnx logging and error presentation
rocksdanister Oct 9, 2024
7f04d0e
Language selector
rocksdanister Oct 10, 2024
fce3de7
Refactored uwp file structure to match avalonia
rocksdanister Oct 11, 2024
21d0b17
Location selector refactor
rocksdanister Oct 11, 2024
29405f6
Style fix IsExtendedIntoWindowDecorations
rocksdanister Oct 11, 2024
2fbc4f0
Searchbox fix
rocksdanister Oct 11, 2024
ef37fbf
Updated translations
rocksdanister Oct 11, 2024
cb4c104
MacOS native menu impl
rocksdanister Oct 12, 2024
cc8d001
MacOS help nativemenu
rocksdanister Oct 12, 2024
2da48c7
Update checking
rocksdanister Oct 12, 2024
26e722a
Fixed duplicate update event
rocksdanister Oct 12, 2024
cacc721
Welcome message
rocksdanister Oct 12, 2024
0c72bf8
Turned off snapshot antialias for perf
rocksdanister Oct 12, 2024
8d54897
Delete duplicate gitignore
rocksdanister Oct 12, 2024
ffd8e44
Updated Avalonia package version and removed unused buildprop
rocksdanister Oct 12, 2024
a7b4e2c
Updated avalonia dependencies
rocksdanister Oct 12, 2024
872395c
Fixed shadermodel copy constructor not updating shaderuri
rocksdanister Oct 13, 2024
c179184
ShaderModel default uniforms are made in base class
rocksdanister Oct 13, 2024
1a7fe93
Refactored computesharp runners to use shaderuniform dictionary
rocksdanister Oct 13, 2024
5e58413
Restore IsRandomN14 back to private
rocksdanister Oct 13, 2024
f9635ae
Fixed cloud day/night not working (uwp)
rocksdanister Oct 13, 2024
0bc8370
Adjust shadow and margins to match uwp
rocksdanister Oct 13, 2024
94a28c6
Fixed top-margin when content not extended to titlebar
rocksdanister Oct 15, 2024
88a0f79
Adjust header and clock shadow
rocksdanister Oct 15, 2024
966e78b
Platform specific update manifest
rocksdanister Oct 16, 2024
65f8e27
Linux build script
rocksdanister Oct 17, 2024
8648a52
Linux build enhancements
rocksdanister Oct 17, 2024
a4e10fc
Removed duplicate FluentTheme
rocksdanister Oct 18, 2024
2cc6582
Changed avalonia title Beta to Preview
rocksdanister Oct 19, 2024
131a816
Update .fpm
rocksdanister Oct 20, 2024
aba6011
Updated translations
rocksdanister Oct 21, 2024
9e6513d
Update hero.mp4
rocksdanister Oct 21, 2024
6a937b7
Shader cross-fade (Avalonia) and control refactor
rocksdanister Oct 24, 2024
513a3c6
New customise ui (avalonia)
rocksdanister Oct 24, 2024
661a43d
Autosize customise menu (Avalonia)
rocksdanister Oct 25, 2024
034e80d
Weather customise and selection moved to single flyout (uwp)..
rocksdanister Oct 25, 2024
72de898
Adjusted Eye lottie animation color
rocksdanister Oct 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 13 additions & 0 deletions build/linux/.fpm
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-s dir -C package
--name livelyweather
--description "Weather app powered by gpu shader animations."
--url "https://www.rocksdanister.com/weather"
--maintainer "Rocksdanister <[email protected]>"
--vendor "Rocksdanister"
--license "MIT"
--version 2.0.0.0
--architecture amd64
--deb-no-default-config-files
--deb-compression xz
--rpm-compression xz
.
21 changes: 21 additions & 0 deletions build/linux/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Using [fpm](https://github.com/jordansissel/fpm) to create installer packages (deb, rpm.)

Make the build script executable `chmod +x build_packages.sh` and run `./build_packages.sh`

The script will create a `package` directory using the application files directory `build` and `resources` as follows:
```
package/
├── usr/
│ ├── bin/
│ │ └── livelyweather (symlink to ../lib/livelyweather/Drizzle.UI.Avalonia.Desktop)
│ └── lib/
│ └── livelyweather/
│ ├── Drizzle.UI.Avalonia.Desktop
│ ├── (other application files)
├── usr/share/
│ ├── applications/
│ │ └── com.rocksdanister.LivelyWeather.desktop
│ └── icons/hicolor/256x256/apps/
│ └── com.rocksdanister.LivelyWeather.png
```
Then create packages using the .fpm configuration file.
28 changes: 28 additions & 0 deletions build/linux/build_packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Clean previous package directory
rm -rf package/
mkdir -p package/usr/bin
mkdir -p package/usr/lib/livelyweather
mkdir -p package/usr/share/applications
mkdir -p package/usr/share/icons/hicolor/256x256/apps

# Copy application files
cp -r build/* package/usr/lib/livelyweather/

# Create symlink
ln -s ../lib/livelyweather/Drizzle.UI.Avalonia.Desktop package/usr/bin/livelyweather

# Copy desktop file and icon
cp resources/com.rocksdanister.LivelyWeather.desktop package/usr/share/applications/
cp resources/com.rocksdanister.LivelyWeather.png package/usr/share/icons/hicolor/256x256/apps/

# Ensure executables have correct permissions
chmod +x package/usr/lib/livelyweather/Drizzle.UI.Avalonia.Desktop

# Build package
fpm -t deb
fpm -t rpm
# tar -> tar.gz
fpm -t tar
gzip livelyweather.tar
9 changes: 9 additions & 0 deletions build/linux/resources/com.rocksdanister.LivelyWeather.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Desktop Entry]
Name=Lively Weather
Comment=Weather app powered by gpu shader animations.
Exec=livelyweather
Icon=com.rocksdanister.LivelyWeather
Terminal=false
Type=Application
Categories=Utility;Science;Geography;X-Weather;
StartupNotify=true
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/hero.mp4
Binary file not shown.
8 changes: 7 additions & 1 deletion src/Drizzle.Common/Constants/UserSettingsConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public static class UserSettingsConstants

public const string SelectedWeatherProvider = "SelectedWeatherProvider";

public const string SelectedLanguageCode = "SelectedLanguageCode";

public const string UseSystemDefaultLanguage = "UseSystemDefaultLanguage";

// Custom user selected units.

public const string SelectedTemperatureUnit = "SelectedTemperatureUnit";
Expand Down Expand Up @@ -80,6 +84,8 @@ public static class UserSettingsConstants
{ SelectedVisibilityUnit, VisibilityUnits.km },
{ SelectedPressureUnit, PressureUnits.hPa_mb },
{ SelectedMainGraphType, GraphType.temperature },
{ SelectedPrecipitationUnit, PrecipitationUnits.mm }
{ SelectedPrecipitationUnit, PrecipitationUnits.mm },
{ SelectedLanguageCode, string.Empty }, //en-US, zh-CN
{ UseSystemDefaultLanguage, true } // Ignores "SelectedLanguageCode"
};
}
24 changes: 12 additions & 12 deletions src/Drizzle.Common/Extensions/TaskExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ namespace Drizzle.Common.Extensions;
//ref: https://www.youtube.com/watch?v=O1Tx-k4Vao0
public static class TaskExtensions
{
//public async static void Await<T>(this Task<T> task, Action<T> completedCallBack, Action<Exception> errorCallBack)
//{
// try
// {
// T result = await task;
// completedCallBack?.Invoke(result);
// }
// catch (Exception ex)
// {
// errorCallBack?.Invoke(ex);
// }
//}
public async static void Await<T>(this Task<T> task, Action<T> completedCallBack, Action<Exception> errorCallBack)
{
try
{
T result = await task;
completedCallBack?.Invoke(result);
}
catch (Exception ex)
{
errorCallBack?.Invoke(ex);
}
}

public async static void Await(this Task task, Action completedCallBack, Action<Exception> errorCallBack)
{
Expand Down
14 changes: 14 additions & 0 deletions src/Drizzle.Common/Helpers/BuildInfoUtil.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Drizzle.Common.Helpers;

public static class BuildInfoUtil
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Minor Code Smell", "S3400:Methods should not return constants", Justification = "Value changes based on build setting.")]
public static bool IsDebugBuild()
{
#if DEBUG
return true;
#else
return false;
#endif
}
}
44 changes: 0 additions & 44 deletions src/Drizzle.Common/Helpers/IDownloadUtil.cs

This file was deleted.

12 changes: 10 additions & 2 deletions src/Drizzle.Common/Helpers/JsonUtil.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Drizzle.Common.Helpers
{
Expand All @@ -21,6 +19,16 @@ public static T Load<T>(string filePath)
return tmp != null ? tmp : throw new InvalidOperationException("json null/corrupt");
}

public static T Load<T>(Stream stream)
{
using var reader = new StreamReader(stream);
using var jsonReader = new JsonTextReader(reader);
var serializer = new JsonSerializer();
var tmp = serializer.Deserialize<T>(jsonReader);

return tmp != null ? tmp : throw new InvalidOperationException("json null/corrupt");
}

public static void Save<T>(string filePath, T data)
{
JsonSerializer serializer = new JsonSerializer
Expand Down
39 changes: 39 additions & 0 deletions src/Drizzle.Common/Helpers/MathUtil.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;

namespace Drizzle.Common.Helpers
{
public static class MathUtil
{
public static float Lerp(float start, float target, float by) => start * (1 - by) + target * by;

public static double RangePercentage(double number, double rangeMin, double rangeMax)
{
var percentage = ((number - rangeMin) * 100) / (rangeMax - rangeMin);
if (percentage > 100)
percentage = 100;
else if (percentage < 0)
percentage = 0;

return percentage;
}

public static double DegreeToRadians(double degree) => degree * Math.PI / 180;

public static float NormalizeAngle(float degree) => degree < 0 ? 360 + degree : degree;

public static float ConvertToRange(float oldStart, float oldEnd, float newStart, float newEnd, float value)
{
var scale = (newEnd - newStart) / (oldEnd - oldStart);
return newStart + ((value - oldStart) * scale);
}

// Credit: https://gist.github.com/adrianstevens/8163205
public static string DegreeToCardinalString(float degree)
{
var cardinals = new string[] { "N", "NE", "E", "SE", "S", "SW", "W", "NW", "N" };
var value = NormalizeAngle(degree);
var index = (int)Math.Round(value % 360 / 45);
return cardinals[index];
}
}
}
22 changes: 15 additions & 7 deletions src/Drizzle.Common/Services/IAppUpdaterService.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
using Drizzle.Models.Enums;
using System;
using System.Threading.Tasks;

namespace Drizzle.Common.Services
namespace Drizzle.Common.Services;

public interface IAppUpdaterService
{
public interface IAppUpdaterService
{
}
/// <summary>
/// Utc time since last update checked succesfully.
/// </summary>
DateTime LastCheckedTime { get; }
AppUpdateStatus LastCheckedStatus { get; }
Task<AppUpdateStatus> CheckUpdateAsync();
void Start();

event EventHandler<AppUpdateStatus> UpdateChecked;
}
19 changes: 19 additions & 0 deletions src/Drizzle.Common/Services/IDownloadService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Threading;
using System.Threading.Tasks;

namespace Drizzle.Common.Services;

public interface IDownloadService
{
/// <summary>
/// Downloads a file from the specified URL to the given file path.
/// </summary>
/// <param name="url">The file download uri.</param>
/// <param name="filePath">The destination file path.</param>
/// <param name="progress">Reports progress.
/// The first parameter is the downloaded size in MB, and the second is the total size in MB.</param>
/// <param name="cancellationToken">A token to cancel the download operation.</param>
/// <returns>A Task that completes when the download is finished, or throws an exception on failure.</returns>
Task DownloadFile(Uri url, string filePath, IProgress<(double downloaded, double total)> progress, CancellationToken cancellationToken);
}
15 changes: 15 additions & 0 deletions src/Drizzle.Common/Services/IFileService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.IO;
using System.Runtime.InteropServices.ComTypes;
using System.Threading.Tasks;

namespace Drizzle.Common.Services;

public interface IFileService
{
string LocalFolderPath { get; }
string TempFolderPath { get; }
string LogFolderPath { get; }
string CachePath { get; }
Task<(Stream stream, string fileName)> OpenFileAsync();
Task<(Stream stream, string fileName)> OpenImageFileAsync();
}
12 changes: 12 additions & 0 deletions src/Drizzle.Common/Services/ILauncherService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Threading.Tasks;

namespace Drizzle.Common.Services
{
public interface ILauncherService
{
public Task<bool> OpenBrowserAsync(Uri uri);
public Task<bool> OpenBrowserAsync(string url);
public Task<bool> OpenFileAsync(string filePath);
}
}
8 changes: 8 additions & 0 deletions src/Drizzle.Common/Services/IResourceService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Drizzle.Common.Services;

public interface IResourceService
{
string GetString(string resource);
void SetCulture(string name);
void SetSystemDefaultCulture();
}
16 changes: 14 additions & 2 deletions src/Drizzle.Common/Services/ISystemInfoProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,26 @@ public interface ISystemInfoProvider
/// <summary>
/// Returns true is the current device is a Desktop.
/// </summary>
bool IsDesktop();
bool IsDesktop { get; }

/// <summary>
/// Returns true is the current
/// device is Xbox or other device
/// optimized for a 10-foot viewing
/// distance.
/// </summary>
bool IsTenFoot();
bool IsTenFoot { get; }

bool IsHardwareAccelerated { get; }

public bool IsFirstRun { get; }

public bool IsAppUpdated { get; }

public string AppName { get; }

public Version AppVersion { get; }

public string GpuName { get; }
}
}
10 changes: 10 additions & 0 deletions src/Drizzle.Common/Services/IUserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ public interface IUserSettings
/// <returns>The desired value or returns the default.</returns>
T? GetAndDeserialize<T>(string settingKey);

/// <summary>
/// Retrieves the value for the desired settings key
/// and performs json deserialization on the stored value.
/// </summary>
/// <typeparam name="T">Type of the value.</typeparam>
/// <param name="settingKey">The settings key, generally found in <see cref="UserSettingsConstants"/>.</param>
/// <param name="defaultOverride">The default override to use if the setting has no value.</param>
/// <returns>The desired value or returns the default.</returns>
T? GetAndDeserialize<T>(string settingKey, T defaultOverride);

/// <summary>
/// Saves settings into persistent local storage
/// after serializing the object.
Expand Down
7 changes: 7 additions & 0 deletions src/Drizzle.Common/Services/IWindowService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Drizzle.Common.Services;

public interface IWindowService
{
void ShowAboutWindow();
void ShowHelpWindow();
}
Loading