mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-16 02:01:29 -07:00
Dynamically resize supporter grid columns
+ fix bootstrapper bug from yesterday
This commit is contained in:
parent
6a93624040
commit
b3a1b1c55e
@ -629,6 +629,9 @@ namespace Bloxstrap
|
||||
|
||||
if (Directory.Exists(AppData.Directory))
|
||||
{
|
||||
if (Directory.Exists(AppData.OldDirectory))
|
||||
Directory.Delete(AppData.OldDirectory, true);
|
||||
|
||||
try
|
||||
{
|
||||
// test to see if any files are in use
|
||||
|
@ -10,6 +10,7 @@
|
||||
xmlns:resources="clr-namespace:Bloxstrap.Resources"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="1500" d:DesignWidth="800"
|
||||
SizeChanged="UiPage_SizeChanged"
|
||||
Title="AboutPage"
|
||||
Scrollable="True">
|
||||
<StackPanel Margin="0,0,14,14">
|
||||
@ -93,7 +94,7 @@
|
||||
</ListView.ItemTemplate>
|
||||
<ListView.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<UniformGrid Columns="{Binding SupporterData.Monthly.Columns}" Margin="-4" />
|
||||
<UniformGrid Columns="{Binding Columns}" Margin="-4" />
|
||||
</ItemsPanelTemplate>
|
||||
</ListView.ItemsPanel>
|
||||
</ListView>
|
||||
@ -122,7 +123,7 @@
|
||||
</ListView.ItemTemplate>
|
||||
<ListView.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<UniformGrid Columns="{Binding SupporterData.OneOff.Columns}" Margin="-4" />
|
||||
<UniformGrid Columns="{Binding Columns}" Margin="-4" />
|
||||
</ItemsPanelTemplate>
|
||||
</ListView.ItemsPanel>
|
||||
</ListView>
|
||||
|
@ -1,4 +1,6 @@
|
||||
using Bloxstrap.UI.ViewModels.About;
|
||||
using System.Windows;
|
||||
|
||||
using Bloxstrap.UI.ViewModels.About;
|
||||
|
||||
namespace Bloxstrap.UI.Elements.About.Pages
|
||||
{
|
||||
@ -7,10 +9,15 @@ namespace Bloxstrap.UI.Elements.About.Pages
|
||||
/// </summary>
|
||||
public partial class SupportersPage
|
||||
{
|
||||
private readonly SupportersViewModel _viewModel = new();
|
||||
|
||||
public SupportersPage()
|
||||
{
|
||||
DataContext = new SupportersViewModel();
|
||||
DataContext = _viewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void UiPage_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
=> _viewModel.WindowResizeEvent?.Invoke(sender, e);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Bloxstrap.UI.ViewModels.About
|
||||
using System.Windows;
|
||||
|
||||
namespace Bloxstrap.UI.ViewModels.About
|
||||
{
|
||||
public class SupportersViewModel : NotifyPropertyChangedViewModel
|
||||
{
|
||||
@ -8,12 +10,32 @@
|
||||
|
||||
public string LoadError { get; set; } = "";
|
||||
|
||||
public int Columns { get; set; } = 3;
|
||||
|
||||
public SizeChangedEventHandler? WindowResizeEvent;
|
||||
|
||||
public SupportersViewModel()
|
||||
{
|
||||
WindowResizeEvent += OnWindowResize;
|
||||
|
||||
// this will cause momentary freezes only when ran under the debugger
|
||||
LoadSupporterData();
|
||||
}
|
||||
|
||||
private void OnWindowResize(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
if (!e.WidthChanged)
|
||||
return;
|
||||
|
||||
int newCols = (int)Math.Floor(e.NewSize.Width / 200);
|
||||
|
||||
if (Columns == newCols)
|
||||
return;
|
||||
|
||||
Columns = newCols;
|
||||
OnPropertyChanged(nameof(Columns));
|
||||
}
|
||||
|
||||
public async void LoadSupporterData()
|
||||
{
|
||||
const string LOG_IDENT = "AboutViewModel::LoadSupporterData";
|
||||
|
Loading…
Reference in New Issue
Block a user