Skip to content

Commit

Permalink
Add full page loading
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharykeeping committed Oct 17, 2024
1 parent b0670df commit 37df4c8
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 86 deletions.
7 changes: 0 additions & 7 deletions src/MobileUI/Controls/ProfileActivity.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@
Style="{StaticResource LabelBold}"
Margin="0, 5" />

<ActivityIndicator
HorizontalOptions="Center"
VerticalOptions="Center"
IsRunning="True"
Color="{StaticResource primary}"
IsVisible="{Binding IsLoading}" />

<VerticalStackLayout
BindableLayout.ItemsSource="{Binding RecentActivity}"
Spacing="8">
Expand Down
8 changes: 4 additions & 4 deletions src/MobileUI/Features/Flyout/FlyoutFooter.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,25 @@
ColumnDefinitions="Auto,*">
<Grid.GestureRecognizers>
<TapGestureRecognizer NumberOfTapsRequired="1"
Command="{Binding MyQrCodeTappedCommand}"/>
Command="{Binding MyProfileTappedCommand}"/>
</Grid.GestureRecognizers>
<Label Grid.Column="0"
HeightRequest="30"
WidthRequest="30"
VerticalOptions="Center"
VerticalTextAlignment="Center"
FontSize="16"
FontFamily="FluentIcons"
FontFamily="FluentIconsFilled"
TextColor="#DDDDDD"
Text="&#xf636;">
Text="&#xf5ca;">
</Label>
<Label Grid.Column="1"
Style="{StaticResource LabelBold}"
TextColor="#DDDDDD"
HorizontalOptions="Start"
VerticalOptions="Center"
FontSize="16"
Text="My QR Code" />
Text="My Profile" />
</Grid>
</VerticalStackLayout>
<VerticalStackLayout VerticalOptions="Start">
Expand Down
8 changes: 2 additions & 6 deletions src/MobileUI/Features/Flyout/FlyoutFooterViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,9 @@ public FlyoutFooterViewModel(IUserService userService, IAuthenticationService au
}

[RelayCommand]
private async Task MyQrCodeTapped()
private async Task MyProfileTapped()
{
var granted = await _permissionsService.CheckAndRequestPermission<Permissions.Camera>();
if (granted)
{
await App.Current.MainPage.Navigation.PushModalAsync<ScanPage>(ScanPageSegments.MyCode);
}
await App.Current.MainPage.Navigation.PushModalAsync<MyProfilePage>();
}

[RelayCommand]
Expand Down
58 changes: 37 additions & 21 deletions src/MobileUI/Features/Profile/MyProfilePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,47 @@
</ContentPage.Behaviors>

<ScrollView>
<VerticalStackLayout Margin="15">

<Grid RowDefinitions="Auto, *"
Margin="15,0">

<!-- Close button -->
<Border
HorizontalOptions="End"
BackgroundColor="{StaticResource Background}"
StrokeShape="Ellipse"
StrokeThickness="0"
IsVisible="{Binding ShowCloseButton}">
<Border.GestureRecognizers>
<TapGestureRecognizer Command="{Binding ClosePageCommand}" />
</Border.GestureRecognizers>
<Label
FontFamily="FluentIcons"
Text="&#xe4c3;"
FontSize="35"
FontAutoScalingEnabled="False"
TextColor="{StaticResource primary}" />
</Border>
<Grid Grid.Row="0"
Margin="0,10">
<Border
HorizontalOptions="End"
BackgroundColor="{StaticResource Background}"
StrokeShape="Ellipse"
StrokeThickness="0"
IsVisible="{Binding ShowCloseButton}">
<Border.GestureRecognizers>
<TapGestureRecognizer Command="{Binding ClosePageCommand}" />
</Border.GestureRecognizers>
<Label
FontFamily="FluentIcons"
Text="&#xe4c3;"
FontSize="35"
FontAutoScalingEnabled="False"
TextColor="{StaticResource primary}" />
</Border>
</Grid>

<controls:ProfileStats Margin="0,15,0,0" />
<VerticalStackLayout Grid.Row="1"
Spacing="15"
IsVisible="{Binding Path=IsLoading, Converter={mct:InvertedBoolConverter}}">
<controls:ProfileStats />

<controls:ProfileActivity Margin="0,15,0,0" />
<controls:ProfileActivity />
</VerticalStackLayout>

</VerticalStackLayout>
<ActivityIndicator
Grid.Row="1"
HorizontalOptions="Center"
VerticalOptions="Center"
Color="{StaticResource SSWRed}"
IsEnabled="{Binding IsLoading}"
IsRunning="{Binding IsLoading}"
IsVisible="{Binding IsLoading}" />
</Grid>
</ScrollView>

</ContentPage>
1 change: 1 addition & 0 deletions src/MobileUI/Features/Profile/MyProfilePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public MyProfilePage(MyProfileViewModel vm, IFirebaseAnalyticsService firebaseAn

protected override async void OnAppearing()
{
base.OnAppearing();
_firebaseAnalyticsService.Log("MyProfilePage");
await _viewModel.Initialise();
}
Expand Down
89 changes: 52 additions & 37 deletions src/MobileUI/Features/Profile/OthersProfilePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,62 @@
</ContentPage.Behaviors>

<ScrollView>
<VerticalStackLayout Margin="15">

<Grid RowDefinitions="Auto, *"
Margin="15,0">

<!-- Close button -->
<Border
HorizontalOptions="End"
BackgroundColor="{StaticResource Background}"
StrokeShape="Ellipse"
StrokeThickness="0"
IsVisible="{Binding ShowCloseButton}">
<Border.GestureRecognizers>
<TapGestureRecognizer Command="{Binding ClosePageCommand}" />
</Border.GestureRecognizers>
<Label
FontFamily="FluentIcons"
Text="&#xe4c3;"
FontSize="35"
FontAutoScalingEnabled="False"
TextColor="{StaticResource primary}" />
</Border>
<Grid Grid.Row="0"
Margin="0,10">
<Border
HorizontalOptions="End"
BackgroundColor="{StaticResource Background}"
StrokeShape="Ellipse"
StrokeThickness="0"
IsVisible="{Binding ShowCloseButton}">
<Border.GestureRecognizers>
<TapGestureRecognizer Command="{Binding ClosePageCommand}" />
</Border.GestureRecognizers>
<Label
FontFamily="FluentIcons"
Text="&#xe4c3;"
FontSize="35"
FontAutoScalingEnabled="False"
TextColor="{StaticResource primary}" />
</Border>
</Grid>

<controls:ProfileStats Margin="0,15,0,0" />
<VerticalStackLayout Grid.Row="1"
Spacing="15"
IsVisible="{Binding Path=IsLoading, Converter={mct:InvertedBoolConverter}}">
<controls:ProfileStats />

<Button Text="Get in touch"
TextTransform="Uppercase"
Margin="0,15,0,0"
Style="{StaticResource LabelBold}"
HeightRequest="50"
FontSize="16"
BackgroundColor="{StaticResource SSWRed}"
CornerRadius="8"
Command="{Binding EmailUserCommand}"
IsVisible="{Binding IsStaff}">
<Button.ImageSource>
<FontImageSource Glyph="&#xf0e0;"
FontFamily="FA6Solid"
Size="20"/>
</Button.ImageSource>
</Button>
<Button Text="Get in touch"
TextTransform="Uppercase"
Style="{StaticResource LabelBold}"
HeightRequest="50"
FontSize="16"
BackgroundColor="{StaticResource SSWRed}"
CornerRadius="8"
Command="{Binding EmailUserCommand}"
IsVisible="{Binding IsStaff}">
<Button.ImageSource>
<FontImageSource Glyph="&#xf0e0;"
FontFamily="FA6Solid"
Size="20" />
</Button.ImageSource>
</Button>

<controls:ProfileActivity Margin="0,15,0,0" />
<controls:ProfileActivity />
</VerticalStackLayout>

</VerticalStackLayout>
<ActivityIndicator
Grid.Row="1"
HorizontalOptions="Center"
VerticalOptions="Center"
Color="{StaticResource SSWRed}"
IsEnabled="{Binding IsLoading}"
IsRunning="{Binding IsLoading}"
IsVisible="{Binding IsLoading}" />
</Grid>
</ScrollView>
</ContentPage>
1 change: 1 addition & 0 deletions src/MobileUI/Features/Profile/OthersProfilePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public OthersProfilePage(OthersProfileViewModel vm, IFirebaseAnalyticsService fi

protected override async void OnAppearing()
{
base.OnAppearing();
_firebaseAnalyticsService.Log("OthersProfilePage");
await _viewModel.Initialise();
}
Expand Down
14 changes: 3 additions & 11 deletions src/MobileUI/Features/Profile/ProfileViewModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,29 +90,20 @@ public ProfileViewModelBase(
userService.LinkedInProfileObservable().Subscribe(linkedIn => LinkedInUrl = linkedIn);
userService.GitHubProfileObservable().Subscribe(gitHub => GitHubUrl = gitHub);
userService.TwitterProfileObservable().Subscribe(twitter => TwitterUrl = twitter);
userService.CompanyUrlObservable().Subscribe(company =>
{
CompanyUrl = company;

if (!IsStaff)
{
Title = company;
}
});
userService.CompanyUrlObservable().Subscribe(company => CompanyUrl = company);
}

protected async Task _initialise()
{
IsLoading = true;
await LoadProfileSections();
IsLoading = false;
}

protected async Task LoadProfileSections()
{
if (!_loadingProfileSectionsSemaphore.Wait(0))
return;

IsLoading = true;
var profileTask = _userService.GetUserAsync(UserId);
var socialMediaTask = LoadSocialMedia();

Expand All @@ -134,6 +125,7 @@ protected async Task LoadProfileSections()
await UpdateSkillsSectionIfRequired();

_loadingProfileSectionsSemaphore.Release();
IsLoading = false;
}

private async Task LoadSocialMedia()
Expand Down
1 change: 1 addition & 0 deletions src/MobileUI/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static MauiApp CreateMauiApp()
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
fonts.AddFont("FluentSystemIcons-Regular.ttf", "FluentIcons");
fonts.AddFont("FluentSystemIcons-Filled.ttf", "FluentIconsFilled");
fonts.AddFont("FA6Brands-Regular.otf", "FA6Brands");
fonts.AddFont("FontAwesome6-Regular.otf", "FA6Regular");
fonts.AddFont("FontAwesome6-Solid.otf", "FA6Solid");
Expand Down
Binary file not shown.

0 comments on commit 37df4c8

Please sign in to comment.