-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
911 additions
and
658 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,122 +1,186 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<Shell | ||
x:Class="NuSocial.AppShell" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:fa="clr-namespace:FontAwesome" | ||
xmlns:loc="clr-namespace:NuSocial.Helpers" | ||
xmlns:local="clr-namespace:NuSocial" | ||
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" | ||
xmlns:viewModels="clr-namespace:NuSocial.ViewModels" | ||
xmlns:views="clr-namespace:NuSocial.Views" | ||
x:DataType="viewModels:ShellViewModel" | ||
FlyoutBackdrop="{DynamicResource Gray500}" | ||
FlyoutBackgroundColor="{DynamicResource Tertiary}" | ||
FlyoutIsPresented="{Binding IsPresented, Mode=TwoWay}" | ||
Shell.BackgroundColor="{DynamicResource Tertiary}"> | ||
<Shell.Behaviors> | ||
<toolkit:StatusBarBehavior StatusBarColor="{OnPlatform iOS='#00FFFFFF', Default='#FF0D2647'}" StatusBarStyle="LightContent" /> | ||
</Shell.Behaviors> | ||
|
||
<ShellContent | ||
ContentTemplate="{DataTemplate views:StartView}" | ||
FlyoutItemIsVisible="False" | ||
Route="start" /> | ||
|
||
<FlyoutItem Title="{loc:Translate Home}" Icon="{x:Static fa:FontAwesomeIcons.House}"> | ||
<ShellContent ContentTemplate="{DataTemplate views:MainView}" Route="main" /> | ||
</FlyoutItem> | ||
|
||
<Shell.MenuItemTemplate> | ||
<DataTemplate x:DataType="{x:Type MenuItem}"> | ||
<Grid | ||
Padding="20,0" | ||
ColumnDefinitions="30,*" | ||
HeightRequest="50"> | ||
<!-- ICON --> | ||
<Label | ||
Grid.Column="0" | ||
FontFamily="{DynamicResource FaSolid}" | ||
HorizontalOptions="Center" | ||
Style="{DynamicResource MainMenuIconStyle}" | ||
Text="{x:Static fa:FontAwesomeIcons.ScreenUsers}" | ||
TextColor="{DynamicResource Primary}" | ||
VerticalOptions="Center" | ||
VerticalTextAlignment="Center" /> | ||
|
||
<!-- LABEL --> | ||
<Label | ||
Grid.Column="1" | ||
Margin="{DynamicResource MainMenuFullLabelMargin}" | ||
Padding="10,0,0,0" | ||
LineBreakMode="WordWrap" | ||
Style="{DynamicResource MainMenuLabelStyle}" | ||
Text="{Binding Text}" | ||
TextColor="{DynamicResource Gray200}" | ||
VerticalOptions="Center" | ||
VerticalTextAlignment="Center" /> | ||
|
||
</Grid> | ||
</DataTemplate> | ||
</Shell.MenuItemTemplate> | ||
|
||
<Shell.ItemTemplate> | ||
<DataTemplate x:DataType="{x:Type FlyoutItem}"> | ||
<Grid | ||
Padding="20,0" | ||
ColumnDefinitions="30,*" | ||
HeightRequest="50"> | ||
<!-- ICON --> | ||
<Label | ||
x:Name="IconLabel" | ||
Grid.Column="0" | ||
FontFamily="{DynamicResource FaSolid}" | ||
HorizontalOptions="Center" | ||
Style="{DynamicResource MainMenuIconStyle}" | ||
Text="{Binding Icon}" | ||
TextColor="{DynamicResource Primary}" | ||
VerticalOptions="Center" | ||
VerticalTextAlignment="Center" /> | ||
|
||
<!-- LABEL --> | ||
<Label | ||
x:Name="NameLabel" | ||
Grid.Column="1" | ||
Margin="{DynamicResource MainMenuFullLabelMargin}" | ||
Padding="10,0,0,0" | ||
LineBreakMode="WordWrap" | ||
Style="{DynamicResource MainMenuLabelStyle}" | ||
Text="{Binding Title}" | ||
TextColor="{DynamicResource Gray200}" | ||
VerticalOptions="Center" | ||
VerticalTextAlignment="Center" /> | ||
|
||
<!--<BoxView | ||
x:Name="MenuSep" | ||
Grid.Row="1" | ||
Grid.ColumnSpan="2" | ||
BackgroundColor="{StaticResource Gray600}" | ||
HeightRequest="1" | ||
IsVisible="{Binding ., Converter={StaticResource separatorVisibilityConverter}, ConverterParameter={x:Reference Name=listView}}" />--> | ||
<VisualStateManager.VisualStateGroups> | ||
<VisualStateGroup x:Name="CommonStates"> | ||
<VisualState x:Name="Normal"> | ||
<VisualState.Setters> | ||
<Setter Property="BackgroundColor" Value="Transparent" /> | ||
<Setter TargetName="IconLabel" Property="Label.TextColor" Value="{StaticResource Primary}" /> | ||
<Setter TargetName="NameLabel" Property="Label.TextColor" Value="White" /> | ||
</VisualState.Setters> | ||
</VisualState> | ||
<VisualState x:Name="Selected"> | ||
<VisualState.Setters> | ||
<Setter Property="BackgroundColor" Value="{StaticResource Primary}" /> | ||
<Setter TargetName="IconLabel" Property="Label.TextColor" Value="White" /> | ||
<Setter TargetName="NameLabel" Property="Label.TextColor" Value="{StaticResource Gray300}" /> | ||
</VisualState.Setters> | ||
</VisualState> | ||
</VisualStateGroup> | ||
</VisualStateManager.VisualStateGroups> | ||
</Grid> | ||
</DataTemplate> | ||
</Shell.ItemTemplate> | ||
</Shell> | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<Shell | ||
x:Class="NuSocial.AppShell" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:fa="clr-namespace:FontAwesome" | ||
xmlns:loc="clr-namespace:NuSocial.Helpers" | ||
xmlns:local="clr-namespace:NuSocial" | ||
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" | ||
xmlns:viewModels="clr-namespace:NuSocial.ViewModels" | ||
xmlns:views="clr-namespace:NuSocial.Views" | ||
x:DataType="viewModels:ShellViewModel" | ||
FlyoutBackdrop="{DynamicResource Gray500}" | ||
FlyoutBackgroundColor="{DynamicResource Primary}" | ||
FlyoutIsPresented="{Binding IsPresented, Mode=TwoWay}" | ||
Shell.BackgroundColor="{DynamicResource Primary}"> | ||
<Shell.Behaviors> | ||
<toolkit:StatusBarBehavior StatusBarColor="{OnPlatform iOS='#00FFFFFF', Default='#FF0D2647'}" StatusBarStyle="LightContent" /> | ||
</Shell.Behaviors> | ||
|
||
<ShellContent | ||
ContentTemplate="{DataTemplate views:StartView}" | ||
FlyoutItemIsVisible="False" | ||
Route="start" /> | ||
|
||
<FlyoutItem Title="{loc:Translate Profile}" Icon="{x:Static fa:FontAwesomeIcons.User}"> | ||
<ShellContent ContentTemplate="{DataTemplate views:MainView}" Route="profile" /> | ||
</FlyoutItem> | ||
|
||
<FlyoutItem Title="{loc:Translate Relays}" Icon="{x:Static fa:FontAwesomeIcons.Globe}"> | ||
<ShellContent ContentTemplate="{DataTemplate views:RelaysView}" Route="relays" /> | ||
</FlyoutItem> | ||
|
||
<FlyoutItem Title="{loc:Translate Settings}" Icon="{x:Static fa:FontAwesomeIcons.Gear}"> | ||
<ShellContent ContentTemplate="{DataTemplate views:SettingsView}" Route="settings" /> | ||
</FlyoutItem> | ||
|
||
<TabBar> | ||
<Tab | ||
Title="{loc:Translate Home}" | ||
Icon="{x:Static fa:FontAwesomeIcons.House}" | ||
Route="main"> | ||
<ShellContent | ||
Title="{loc:Translate Posts}" | ||
ContentTemplate="{DataTemplate views:MainView}" | ||
Route="posts" /> | ||
<ShellContent | ||
Title="{loc:Translate PostsAndReplies}" | ||
ContentTemplate="{DataTemplate views:MainView}" | ||
Route="postsAndReplies" /> | ||
</Tab> | ||
|
||
<Tab | ||
Title="{loc:Translate DMs}" | ||
Icon="{x:Static fa:FontAwesomeIcons.Message}" | ||
Route="messages"> | ||
<ShellContent | ||
Title="{loc:Translate DMs}" | ||
ContentTemplate="{DataTemplate views:MessagesView}" | ||
Route="messages?set=dms" /> | ||
<ShellContent | ||
Title="{loc:Translate Requests}" | ||
ContentTemplate="{DataTemplate views:MessagesView}" | ||
Route="messages?set=dmrequests" /> | ||
</Tab> | ||
</TabBar> | ||
<Shell.MenuItemTemplate> | ||
<DataTemplate x:DataType="{x:Type MenuItem}"> | ||
<Grid | ||
Padding="20,0" | ||
ColumnDefinitions="30,*" | ||
HeightRequest="50"> | ||
<!-- ICON --> | ||
<Label | ||
Grid.Column="0" | ||
FontFamily="{DynamicResource FaSolid}" | ||
HorizontalOptions="Center" | ||
Style="{DynamicResource MainMenuIconStyle}" | ||
Text="{x:Static fa:FontAwesomeIcons.ScreenUsers}" | ||
TextColor="{DynamicResource White}" | ||
VerticalOptions="Center" | ||
VerticalTextAlignment="Center" /> | ||
|
||
<!-- LABEL --> | ||
<Label | ||
Grid.Column="1" | ||
Margin="{DynamicResource MainMenuFullLabelMargin}" | ||
Padding="10,0,0,0" | ||
LineBreakMode="WordWrap" | ||
Style="{DynamicResource MainMenuLabelStyle}" | ||
Text="{Binding Text}" | ||
TextColor="{DynamicResource Gray200}" | ||
VerticalOptions="Center" | ||
VerticalTextAlignment="Center" /> | ||
|
||
</Grid> | ||
</DataTemplate> | ||
</Shell.MenuItemTemplate> | ||
|
||
<Shell.ItemTemplate> | ||
<DataTemplate x:DataType="{x:Type FlyoutItem}"> | ||
<Grid | ||
Padding="20,0" | ||
ColumnDefinitions="30,*" | ||
HeightRequest="50"> | ||
<!-- ICON --> | ||
<Label | ||
x:Name="IconLabel" | ||
Grid.Column="0" | ||
FontFamily="{DynamicResource FaSolid}" | ||
HorizontalOptions="Center" | ||
Style="{DynamicResource MainMenuIconStyle}" | ||
Text="{Binding Icon}" | ||
TextColor="{DynamicResource White}" | ||
VerticalOptions="Center" | ||
VerticalTextAlignment="Center" /> | ||
|
||
<!-- LABEL --> | ||
<Label | ||
x:Name="NameLabel" | ||
Grid.Column="1" | ||
Margin="{DynamicResource MainMenuFullLabelMargin}" | ||
Padding="10,0,0,0" | ||
LineBreakMode="WordWrap" | ||
Style="{DynamicResource MainMenuLabelStyle}" | ||
Text="{Binding Title}" | ||
TextColor="{DynamicResource Gray200}" | ||
VerticalOptions="Center" | ||
VerticalTextAlignment="Center" /> | ||
|
||
<!--<BoxView | ||
x:Name="MenuSep" | ||
Grid.Row="1" | ||
Grid.ColumnSpan="2" | ||
BackgroundColor="{StaticResource Gray600}" | ||
HeightRequest="1" | ||
IsVisible="{Binding ., Converter={StaticResource separatorVisibilityConverter}, ConverterParameter={x:Reference Name=listView}}" />--> | ||
<VisualStateManager.VisualStateGroups> | ||
<VisualStateGroup x:Name="CommonStates"> | ||
<VisualState x:Name="Normal"> | ||
<VisualState.Setters> | ||
<Setter Property="BackgroundColor" Value="Transparent" /> | ||
<Setter TargetName="IconLabel" Property="Label.TextColor" Value="{StaticResource Primary}" /> | ||
<Setter TargetName="NameLabel" Property="Label.TextColor" Value="White" /> | ||
</VisualState.Setters> | ||
</VisualState> | ||
<VisualState x:Name="Selected"> | ||
<VisualState.Setters> | ||
<Setter Property="BackgroundColor" Value="{StaticResource Primary}" /> | ||
<Setter TargetName="IconLabel" Property="Label.TextColor" Value="White" /> | ||
<Setter TargetName="NameLabel" Property="Label.TextColor" Value="{StaticResource Gray300}" /> | ||
</VisualState.Setters> | ||
</VisualState> | ||
</VisualStateGroup> | ||
</VisualStateManager.VisualStateGroups> | ||
</Grid> | ||
</DataTemplate> | ||
</Shell.ItemTemplate> | ||
|
||
<Shell.FlyoutFooterTemplate> | ||
<DataTemplate> | ||
<Grid | ||
Padding="20" | ||
RowDefinitions="Auto,50" | ||
RowSpacing="10" | ||
VerticalOptions="End"> | ||
<!-- Version --> | ||
<HorizontalStackLayout HorizontalOptions="Center" Spacing="10"> | ||
<Label | ||
FontSize="{OnIdiom Phone=14, | ||
Tablet=16}" | ||
HorizontalOptions="Center" | ||
Text="{Binding AppVersion}" | ||
TextColor="{DynamicResource White}" /> | ||
</HorizontalStackLayout> | ||
|
||
<!-- Logout --> | ||
<Button | ||
Grid.Row="1" | ||
BackgroundColor="{DynamicResource Blue100Accent}" | ||
Command="{Binding LogoutPressedCommand}" | ||
Text="{loc:Translate Logout}" /> | ||
</Grid> | ||
</DataTemplate> | ||
</Shell.FlyoutFooterTemplate> | ||
</Shell> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using SQLite; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Security.Cryptography; | ||
using System.Security.Policy; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NuSocial.Models | ||
{ | ||
public enum RelayType | ||
{ | ||
Regular, | ||
Ephemeral, | ||
NostrWalletConnect | ||
} | ||
|
||
public class Relay | ||
{ | ||
public Relay():this("wss://") | ||
{ | ||
} | ||
|
||
public Relay(string address, bool canRead = true, bool canWrite = true) | ||
{ | ||
Address = address; | ||
CanRead = canRead; | ||
CanWrite = canWrite; | ||
} | ||
|
||
[Ignore] | ||
public Uri? Uri | ||
{ | ||
get | ||
{ | ||
if (!string.IsNullOrEmpty(Address)) | ||
{ | ||
return new Uri(Address); | ||
} | ||
else return null; | ||
} | ||
} | ||
|
||
[Ignore] | ||
public bool IsEphemeral => RelayType == RelayType.Ephemeral; | ||
|
||
[PrimaryKey] | ||
public string Address { get; set; } | ||
|
||
public RelayType RelayType { get; set; } = RelayType.Regular; | ||
|
||
public bool CanRead { get; set; } | ||
public bool CanWrite { get; set; } | ||
} | ||
|
||
public class Post | ||
{ | ||
public string Content { get; set; } | ||
|
||
[PrimaryKey] | ||
public string Hash { get; set; } | ||
|
||
public void ComputeHash() | ||
{ | ||
byte[] bytes = SHA256.HashData(Encoding.UTF8.GetBytes(Content)); | ||
var builder = new StringBuilder(); | ||
for (int i = 0; i < bytes.Length; i++) | ||
{ | ||
builder.Append(bytes[i].ToString("x2", CultureInfo.InvariantCulture)); | ||
} | ||
Hash = builder.ToString(); | ||
} | ||
} | ||
|
||
public class MerkleNode | ||
{ | ||
public string Hash { get; set; } | ||
public MerkleNode Left { get; set; } | ||
public MerkleNode Right { get; set; } | ||
} | ||
} |
Oops, something went wrong.