Browse Source

user groups test page

master
gene 2 years ago
parent
commit
256325accf
  1. 9
      CircleViewerMaui/App.xaml.cs
  2. 8
      CircleViewerMaui/AppShell.xaml
  3. 12
      CircleViewerMaui/CircleViewerMaui.csproj
  4. 5
      CircleViewerMaui/MainPage.xaml
  5. 10
      CircleViewerMaui/MainPage.xaml.cs
  6. 56
      CircleViewerMaui/UserGroups.xaml
  7. 41
      CircleViewerMaui/UserGroups.xaml.cs

9
CircleViewerMaui/App.xaml.cs

@ -1,7 +1,12 @@
namespace CircleViewerMaui;
using CDPShared;
namespace CircleViewerMaui;
public partial class App : Application public partial class App : Application
{ {
private static CDPWorker _cdp;
public static CDPWorker CDP =>_cdp;
private string syncFusionLicenseKey = "MTg3MzUyM0AzMjMxMmUzMTJlMzQzMVhOUDNaUUxSMUExWTB3a1EzK294VjhKcGh3eENlanRIdXR2aWVrSGZUVTg9"; private string syncFusionLicenseKey = "MTg3MzUyM0AzMjMxMmUzMTJlMzQzMVhOUDNaUUxSMUExWTB3a1EzK294VjhKcGh3eENlanRIdXR2aWVrSGZUVTg9";
public App() public App()
{ {
@ -9,7 +14,7 @@ public partial class App : Application
//Register SyncFusion license //Register SyncFusion license
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense(syncFusionLicenseKey); Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense(syncFusionLicenseKey);
_cdp = new CDPWorker();
InitializeComponent(); InitializeComponent();
MainPage = new AppShell(); MainPage = new AppShell();

8
CircleViewerMaui/AppShell.xaml

@ -5,9 +5,15 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:CircleViewerMaui" xmlns:local="clr-namespace:CircleViewerMaui"
Shell.FlyoutBehavior="Disabled"> Shell.FlyoutBehavior="Disabled">
<TabBar>
<ShellContent <ShellContent
Title="PDF"
ContentTemplate="{DataTemplate local:MainPage}" ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" /> Route="MainPage" />
<ShellContent
Title="User Groups"
ContentTemplate="{DataTemplate local:UserGroups}"
Route="UserGroups" />
</TabBar>
</Shell> </Shell>

12
CircleViewerMaui/CircleViewerMaui.csproj

@ -64,4 +64,16 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Compile Update="UserGroups.xaml.cs">
<DependentUpon>UserGroups.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<MauiXaml Update="UserGroups.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>
</Project> </Project>

5
CircleViewerMaui/MainPage.xaml

@ -4,11 +4,6 @@
xmlns:pdfViewer="http://schemas.syncfusion.com/maui" xmlns:pdfViewer="http://schemas.syncfusion.com/maui"
x:Class="CircleViewerMaui.MainPage"> x:Class="CircleViewerMaui.MainPage">
<ContentPage.MenuBarItems>
<MenuBarItem Text="File">
<MenuFlyoutItem Text="Open" Clicked="onOpenClicked"/>
</MenuBarItem>
</ContentPage.MenuBarItems>
<ContentPage.Content> <ContentPage.Content>
<pdfViewer:SfPdfViewer x:Name="PdfViewer" VerticalOptions="Fill"> <pdfViewer:SfPdfViewer x:Name="PdfViewer" VerticalOptions="Fill">
</pdfViewer:SfPdfViewer> </pdfViewer:SfPdfViewer>

10
CircleViewerMaui/MainPage.xaml.cs

@ -7,7 +7,7 @@ namespace CircleViewerMaui;
public partial class MainPage : ContentPage public partial class MainPage : ContentPage
{ {
int count = 0; int count = 0;
private CDPWorker _cdp;
// private CDPWorker _cdp;
Timer _timer; Timer _timer;
Boolean _bConnected = false; Boolean _bConnected = false;
@ -15,18 +15,16 @@ public partial class MainPage : ContentPage
{ {
using (LogMethod.Log(MethodBase.GetCurrentMethod().ReflectedType.Name)) using (LogMethod.Log(MethodBase.GetCurrentMethod().ReflectedType.Name))
{ {
_cdp = new CDPWorker();
InitializeComponent(); InitializeComponent();
_timer = new Timer(IsReady, null, 250, 250); _timer = new Timer(IsReady, null, 250, 250);
} }
} }
void IsReady(object state) void IsReady(object state)
{ {
if (_bConnected != _cdp.Ready)
if (_bConnected != App.CDP.Ready)
{ {
_bConnected = _cdp.Ready;
_bConnected = App.CDP.Ready;
OnReady(); OnReady();
_timer = null; _timer = null;
} }
@ -76,7 +74,7 @@ public partial class MainPage : ContentPage
{ {
using (LogMethod.Log(MethodBase.GetCurrentMethod().ReflectedType.Name)) using (LogMethod.Log(MethodBase.GetCurrentMethod().ReflectedType.Name))
{ {
var result = await _cdp.Decrypt(fileToLoad);
var result = await App.CDP.Decrypt(fileToLoad);
if (result.Status.Result.GetValueOrDefault(false)) if (result.Status.Result.GetValueOrDefault(false))
{ {
byte[] buf = Convert.FromBase64String(result.DecryptedData); byte[] buf = Convert.FromBase64String(result.DecryptedData);

56
CircleViewerMaui/UserGroups.xaml

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8" ?>
<ContentPage
x:Class="CircleViewerMaui.UserGroups"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://schemas.microsoft.com/dotnet/2021/maui/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:CircleViewerMaui"
mc:Ignorable="d">
<ContentPage.Content>
<Grid Margin="20,20,20,20">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<VerticalStackLayout Grid.Row="0" Grid.Column="0" Padding="10" Margin="10" BackgroundColor="Cornsilk">
<Label
Text="Join User Group"
BackgroundColor="Purple"
TextColor="White"
VerticalOptions="Center"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"/>
<Label
Text="Request code:"
TextColor="Purple"
VerticalOptions="Center"/>
<Entry x:Name="RequestCode" Placeholder="1234"></Entry>
<Label
Text="Verification code:"
TextColor="Purple"
VerticalOptions="Center"/>
<Entry x:Name="VerificationCode" Placeholder="ABCD"></Entry>
<Button x:Name="bnRequestVerfication" Text="Request Verification" Clicked="BnRequestVerfication_OnClicked"/>
</VerticalStackLayout>
<VerticalStackLayout Grid.Row="0" Grid.Column="1" Padding="10" Margin="10" BackgroundColor="Cornsilk">
<Label
Text="User Groups"
BackgroundColor="Purple"
TextColor="White"
VerticalOptions="Center"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"/>
<Picker x:Name="circlePicker" Title="Default User Group">
</Picker>
</VerticalStackLayout>
</Grid>
</ContentPage.Content>
</ContentPage>

41
CircleViewerMaui/UserGroups.xaml.cs

@ -0,0 +1,41 @@
using CircleSDK.Model;
using CommunityToolkit.Maui.Alerts;
using CommunityToolkit.Maui.Core;
namespace CircleViewerMaui
{
public partial class UserGroups : ContentPage
{
public List<CircleInfo> Circles;
public UserGroups()
{
InitializeComponent();
Circles = new List<CircleInfo>(App.CDP.Circles);
// Circles = App.CDP.Circles;
// lvCircles.ItemsSource = App.CDP.Circles;
circlePicker.ItemsSource = App.CDP.Circles;
circlePicker.ItemDisplayBinding = new Binding("CircleName");
}
private async void BnRequestVerfication_OnClicked(object sender, EventArgs e)
{
var reply = await App.CDP.ProcessInvite(RequestCode.Text, VerificationCode.Text);
if (reply.Status.Result.GetValueOrDefault(false))
{
ShowToast("Failed to process request.");
}
else
{
ShowToast("Request has be submitted.");
}
}
async void ShowToast(string text)
{
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
ToastDuration duration = ToastDuration.Short;
double fontSize = 14;
var toast = Toast.Make(text, duration, fontSize);
await toast.Show(cancellationTokenSource.Token);
}
}
}
Loading…
Cancel
Save