Skip to content

Commit

Permalink
Add ToolsPage;
Browse files Browse the repository at this point in the history
Add ShareCommunity.
  • Loading branch information
aiguoli committed Oct 6, 2023
1 parent 18cfcce commit 245ef03
Show file tree
Hide file tree
Showing 30 changed files with 684 additions and 121 deletions.
Binary file added Assets/link-share.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 84 additions & 0 deletions Controls/ItemCard.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<ResourceDictionary
x:Class="SimpleList.Controls.ItemCard"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:data="using:SimpleList.Models">
<DataTemplate x:Key="CardItemControlTemplate" x:DataType="data:ToolItem">
<UserControl>
<Grid
x:Name="controlRoot"
Width="360"
Height="90"
Padding="8"
HorizontalAlignment="Stretch"
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="{StaticResource ControlCornerRadius}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="LayoutVisualStates">
<VisualState x:Name="WideLayout">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="{StaticResource Breakpoint640Plus}" />
</VisualState.StateTriggers>
<VisualState.Setters />
</VisualState>
<VisualState x:Name="NarrowLayout">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="controlRoot.Width" Value="Auto" />
<Setter Target="controlRoot.Height" Value="120" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>

<Grid Width="72" CornerRadius="{ThemeResource ControlCornerRadius}">
<Image
x:Name="gridImage"
Width="48"
VerticalAlignment="Center"
Source="{x:Bind ImagePath}"
Stretch="Uniform" />
</Grid>
<StackPanel
Grid.Column="1"
Grid.ColumnSpan="2"
Margin="16,0,0,0"
VerticalAlignment="Center"
Orientation="Vertical"
Spacing="2">
<TextBlock
x:Name="titleText"
Style="{StaticResource BodyStrongTextBlockStyle}"
Text="{x:Bind Name}"
TextLineBounds="TrimToCapHeight"
TextWrapping="NoWrap" />
<TextBlock
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
RelativePanel.Below="titleText"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{x:Bind Description}"
TextTrimming="CharacterEllipsis" />
</StackPanel>

<InfoBadge
Grid.Column="2"
Width="10"
Margin="4"
VerticalAlignment="Top"
Visibility="Collapsed"/>
</Grid>
</UserControl>
</DataTemplate>

</ResourceDictionary>
12 changes: 12 additions & 0 deletions Controls/ItemCard.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Microsoft.UI.Xaml;

namespace SimpleList.Controls
{
public sealed partial class ItemCard : ResourceDictionary
{
public ItemCard()
{
InitializeComponent();
}
}
}
27 changes: 0 additions & 27 deletions Controls/SettingsCard.xaml

This file was deleted.

46 changes: 0 additions & 46 deletions Controls/SettingsCard.xaml.cs

This file was deleted.

5 changes: 5 additions & 0 deletions MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
<NavigationViewItem x:Uid="NavigationBar_Home" Tag="HomePage" x:Name="HomePageItem" Icon="Home" IsSelected="True" />
<NavigationViewItem x:Uid="NavigationBar_Files" Tag="CloudPage" x:Name="CloudPageItem" Icon="Document" />
<NavigationViewItem x:Uid="NavigationBar_Tasks" Tag="TaskManagerPage" x:Name="TaskManagerItem" Icon="Sort" />
<NavigationViewItem x:Uid="NavigationBar_Tools" Tag="ToolPage" x:Name="ToolPageItem">
<NavigationViewItem.Icon>
<FontIcon Glyph="&#xE74C;" />
</NavigationViewItem.Icon>
</NavigationViewItem>
</NavigationView.MenuItems>

<Frame x:Name="contentFrame" />
Expand Down
14 changes: 10 additions & 4 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.UI.Composition.SystemBackdrops;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media.Animation;
using SimpleList.Pages;
using System;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -43,6 +44,11 @@ private void NavigationView_SelectionChanged(NavigationView sender, NavigationVi
}
}

public void Navigate(Type pageType, object targetPageArguments = null, NavigationTransitionInfo navigationTransitionInfo = null)
{
RootFrame.Navigate(pageType, targetPageArguments, navigationTransitionInfo);
}

public enum BackdropType
{
Mica,
Expand Down Expand Up @@ -175,7 +181,7 @@ private void Window_Closed(object sender, WindowEventArgs args)
m_micaController.Dispose();
m_micaController = null;
}
this.Activated -= Window_Activated;
Activated -= Window_Activated;
m_configurationSource = null;
}

Expand All @@ -191,9 +197,9 @@ private void SetConfigurationSourceTheme()
{
switch (((FrameworkElement)this.Content).ActualTheme)
{
case ElementTheme.Dark: m_configurationSource.Theme = Microsoft.UI.Composition.SystemBackdrops.SystemBackdropTheme.Dark; break;
case ElementTheme.Light: m_configurationSource.Theme = Microsoft.UI.Composition.SystemBackdrops.SystemBackdropTheme.Light; break;
case ElementTheme.Default: m_configurationSource.Theme = Microsoft.UI.Composition.SystemBackdrops.SystemBackdropTheme.Default; break;
case ElementTheme.Dark: m_configurationSource.Theme = SystemBackdropTheme.Dark; break;
case ElementTheme.Light: m_configurationSource.Theme = SystemBackdropTheme.Light; break;
case ElementTheme.Default: m_configurationSource.Theme = SystemBackdropTheme.Default; break;
}
}

Expand Down
10 changes: 10 additions & 0 deletions Models/ToolItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace SimpleList.Models
{
public class ToolItem
{
public string Name { get; set; }
public string Description { get; set; }
public string ImagePath { get; set; }
public string FileName { get; set; }
}
}
37 changes: 37 additions & 0 deletions Models/Tools/ShareCommunity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Microsoft.VisualBasic;
using System;

namespace SimpleList.Models
{
public class Link
{
public int ID { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
public DateTime? DeletedAt { get; set; }
public string title { get; set; }
public string content { get; set; }
public string password { get; set; }
public DateTime expire_date { get; set; }
public int user_id { get; set; }
public int category_id { get; set; }
public int views { get; set; }
}

public class LinkResponse
{
public int code { get; set; }
public Link data { get; set; }
}

public class LinksResponse
{
public int code { get; set; }
public Link[] data { get; set; }
}

public class CreateLinkResponse : LinkResponse
{
public string msg { get; set; }
}
}
26 changes: 26 additions & 0 deletions Pages/ToolPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<Page
x:Class="SimpleList.Pages.ToolPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:SimpleList.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Page.Resources>
<controls:ItemCard />
</Page.Resources>

<Grid x:Name="HeaderGrid" CornerRadius="8,0,0,0">
<GridView
Padding="24,36,24,36"
IsItemClickEnabled="True"
IsSwipeEnabled="False"
ItemTemplate="{StaticResource CardItemControlTemplate}"
ItemsSource="{x:Bind Items, Mode=OneWay}"
ItemClick="OnToolItemClick"
SelectionMode="None" />
</Grid>
</Page>
55 changes: 55 additions & 0 deletions Pages/ToolPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using Microsoft.UI.Xaml.Controls;
using SimpleList.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace SimpleList.Pages
{
public partial class ToolPage : Page, INotifyPropertyChanged
{
public ToolPage()
{
InitializeComponent();
}

protected bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
{
if (Equals(storage, value)) return false;

storage = value;
NotifyPropertyChanged(propertyName);
return true;
}

protected void NotifyPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

private IEnumerable<ToolItem> _items = new List<ToolItem> {
new ToolItem
{
Name = "Share Community",
Description = "Share and browse OneDrive files",
ImagePath = "/Assets/link-share.png",
FileName = "ShareCommunity"
},
};
public IEnumerable<ToolItem> Items
{
get => _items;
set => SetProperty(ref _items, value);
}

public event PropertyChangedEventHandler PropertyChanged;

private void OnToolItemClick(object sender, ItemClickEventArgs e)
{
ToolItem item = (ToolItem)e.ClickedItem;
Type pageType = Type.GetType("SimpleList.Pages.Tools." + item.FileName);
(App.StartupWindow as MainWindow).Navigate(pageType);
}
}
}
Loading

0 comments on commit 245ef03

Please sign in to comment.