Browse Source

trying to get an invite popup working

master
gene 2 years ago
parent
commit
1ca1f1e8bc
  1. 19
      CircleViewerMaui/Activity.xaml
  2. 14
      CircleViewerMaui/Activity.xaml.cs
  3. 16
      CircleViewerMaui/AppShell.xaml
  4. 6
      CircleViewerMaui/CircleViewerMaui.csproj
  5. 11
      CircleViewerMaui/MainPage.xaml.cs
  6. 28
      CircleViewerMaui/Popups/NewInvite.xaml
  7. 23
      CircleViewerMaui/Popups/NewInvite.xaml.cs
  8. 8
      CircleViewerMaui/UserGroups.xaml
  9. 24
      CircleViewerMaui/UserGroups.xaml.cs

19
CircleViewerMaui/Activity.xaml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<ContentPage
x:Class="CircleViewerMaui.Activity"
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>
<Label
HorizontalOptions="Center"
Text="Welcome to .NET MAUI!!!"
TextColor="Purple"
VerticalOptions="Center"/>
</Grid>
</ContentPage.Content>
</ContentPage>

14
CircleViewerMaui/Activity.xaml.cs

@ -0,0 +1,14 @@
using CommunityToolkit.Maui.Views;
using System.ComponentModel;
using CircleViewerMaui.Popups;
namespace CircleViewerMaui
{
public partial class Activity : ContentPage
{
public Activity()
{
InitializeComponent();
}
}
}

16
CircleViewerMaui/AppShell.xaml

@ -5,20 +5,18 @@
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="Flyout"> Shell.FlyoutBehavior="Flyout">
<ShellContent <ShellContent
Title="Viewer" Title="Viewer"
ContentTemplate="{DataTemplate local:MainPage}" ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" /> Route="MainPage" />
<ShellContent <ShellContent
Title="User Groups"
ContentTemplate="{DataTemplate local:UserGroups}"
Route="UserGroups" />
Title="User Groups"
ContentTemplate="{DataTemplate local:UserGroups}"
Route="UserGroups" />
<ShellContent <ShellContent
Title="Activity"
ContentTemplate="{DataTemplate local:UserGroups}"
Route="UserGroups" />
Title="Activity"
ContentTemplate="{DataTemplate local:Activity}"
Route="Activity" />
</Shell> </Shell>

6
CircleViewerMaui/CircleViewerMaui.csproj

@ -71,6 +71,12 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<MauiXaml Update="Activity.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Popups\NewInvite.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="UserGroups.xaml"> <MauiXaml Update="UserGroups.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</MauiXaml> </MauiXaml>

11
CircleViewerMaui/MainPage.xaml.cs

@ -1,5 +1,7 @@
using System.Reflection; using System.Reflection;
using CDPShared; using CDPShared;
using CircleViewerMaui.Popups;
using CommunityToolkit.Maui.Views;
using Syncfusion.Maui.PdfViewer; using Syncfusion.Maui.PdfViewer;
namespace CircleViewerMaui; namespace CircleViewerMaui;
@ -61,8 +63,17 @@ public partial class MainPage : ContentPage
return null; return null;
} }
async Task TestPopup()
{
var popup = new NewInvite("AS3RT3", "POEW");
popup.CanBeDismissedByTappingOutsideOfPopup = false;
this.ShowPopup(popup);
}
private async void onOpenClicked(object sender, EventArgs e) private async void onOpenClicked(object sender, EventArgs e)
{ {
// await TestPopup();
var filePath = await OpenCirFileAsync(); var filePath = await OpenCirFileAsync();
if (filePath != null) if (filePath != null)
{ {

28
CircleViewerMaui/Popups/NewInvite.xaml

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<toolkit:Popup xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="CircleViewerMaui.Popups.NewInvite"
Size="300,100">
<VerticalStackLayout VerticalOptions="Center">
<Grid Margin="10,10,10,10">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column ="0" Text="Invite code:" TextColor="Purple" HorizontalTextAlignment="End" />
<Label Grid.Row="0" Grid.Column ="1" x:Name="lblInviteCode" Text="" TextColor="Purple" HorizontalTextAlignment="Center"/>
<Label Grid.Row="1" Grid.Column ="0" Text="Authorization code:" TextColor="Purple" HorizontalTextAlignment="End" />
<Label Grid.Row="1" Grid.Column ="1" x:Name="lblAuthCode" Text="" TextColor="Purple" HorizontalTextAlignment="Center"/>
<Button Grid.Row="2" Grid.ColumnSpan="2" Text="OK" Clicked="OnOKButtonClicked" HorizontalOptions="Center" />
</Grid>
</VerticalStackLayout>
</toolkit:Popup>

23
CircleViewerMaui/Popups/NewInvite.xaml.cs

@ -0,0 +1,23 @@
using CommunityToolkit.Maui.Views;
namespace CircleViewerMaui.Popups
{
public partial class NewInvite : Popup
{
string _inviteCode;
private string _authCode;
public NewInvite(string inviteCode, string authCode)
{
_inviteCode = inviteCode;
_authCode = authCode;
InitializeComponent();
lblInviteCode.Text = _inviteCode;
lblAuthCode.Text = _authCode;
}
private void OnOKButtonClicked(object sender, EventArgs e)
{
Close();
}
}
}

8
CircleViewerMaui/UserGroups.xaml

@ -30,12 +30,12 @@
Text="Request code:" Text="Request code:"
TextColor="Purple" TextColor="Purple"
VerticalOptions="Center"/> VerticalOptions="Center"/>
<Entry x:Name="RequestCode" Placeholder="1234"></Entry>
<Entry x:Name="RequestCode" Placeholder="1234" TextTransform="Uppercase"></Entry>
<Label <Label
Text="Verification code:" Text="Verification code:"
TextColor="Purple" TextColor="Purple"
VerticalOptions="Center"/> VerticalOptions="Center"/>
<Entry x:Name="VerificationCode" Placeholder="ABCD"></Entry>
<Entry x:Name="VerificationCode" Placeholder="ABCD" TextTransform="Uppercase"></Entry>
<Button x:Name="bnRequestVerfication" Text="Request Verification" Clicked="BnRequestVerfication_OnClicked"/> <Button x:Name="bnRequestVerfication" Text="Request Verification" Clicked="BnRequestVerfication_OnClicked"/>
</VerticalStackLayout> </VerticalStackLayout>
@ -47,8 +47,8 @@
VerticalOptions="Center" VerticalOptions="Center"
HorizontalOptions="Fill" HorizontalOptions="Fill"
HorizontalTextAlignment="Center"/> HorizontalTextAlignment="Center"/>
<Picker x:Name="circlePicker" Title="Default User Group">
</Picker>
<Picker x:Name="circlePicker" Title="Default User Group"/>
<Button x:Name="bnGenInvite" Text="Invite user" Clicked="BnGenInvite_OnClicked"/>
</VerticalStackLayout> </VerticalStackLayout>
</Grid> </Grid>

24
CircleViewerMaui/UserGroups.xaml.cs

@ -1,6 +1,9 @@
using CircleSDK.Model; using CircleSDK.Model;
using CommunityToolkit.Maui.Alerts; using CommunityToolkit.Maui.Alerts;
using CommunityToolkit.Maui.Core; using CommunityToolkit.Maui.Core;
using System.Collections.Generic;
using CircleViewerMaui.Popups;
using CommunityToolkit.Maui.Views;
namespace CircleViewerMaui namespace CircleViewerMaui
{ {
@ -11,9 +14,13 @@ namespace CircleViewerMaui
{ {
InitializeComponent(); InitializeComponent();
Circles = new List<CircleInfo>(App.CDP.Circles); Circles = new List<CircleInfo>(App.CDP.Circles);
// Circles = App.CDP.Circles;
// lvCircles.ItemsSource = App.CDP.Circles;
circlePicker.ItemsSource = App.CDP.Circles;
// Circles = App.CDP.Circles;
// lvCircles.ItemsSource = App.CDP.Circles;
var ordered = App.CDP.Circles.OrderBy(dr => dr.CircleName);
Circles = new List<CircleInfo>();
Circles.AddRange(ordered);
circlePicker.ItemsSource = Circles;
circlePicker.ItemDisplayBinding = new Binding("CircleName"); circlePicker.ItemDisplayBinding = new Binding("CircleName");
} }
@ -37,5 +44,16 @@ namespace CircleViewerMaui
var toast = Toast.Make(text, duration, fontSize); var toast = Toast.Make(text, duration, fontSize);
await toast.Show(cancellationTokenSource.Token); await toast.Show(cancellationTokenSource.Token);
} }
private async void BnGenInvite_OnClicked(object sender, EventArgs e)
{
CircleInfo ci = (CircleInfo) circlePicker.SelectedItem;
if (ci == null)
return;
var invite = await App.CDP.GenInvite(ci.CircleId);
var popup = new NewInvite(invite.Invite.InviteId, invite.Invite.AuthCode);
popup.CanBeDismissedByTappingOutsideOfPopup = false;
this.ShowPopup(popup);
}
} }
} }
Loading…
Cancel
Save