Skip to content

Commit

Permalink
Refactor UI layout and add analytics key to appsettings.json
Browse files Browse the repository at this point in the history
- Refactored UI layout in AppShell.xaml, MessagePreviewItem.xaml, MainView.xaml, and MessagesView.xaml
- Added analytics key to appsettings.json
  • Loading branch information
kfrancis committed May 30, 2023
1 parent 3a64356 commit ed48ccb
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 31 deletions.
3 changes: 2 additions & 1 deletion src/NuSocial.Core/ViewModels/MessagesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ private Task Search()
return Task.CompletedTask;
});
}

[RelayCommand(CanExecute = nameof(IsNotBusy))]
private Task Refresh()
{
Expand Down Expand Up @@ -171,6 +172,6 @@ private void LoadData()
});
}

Messages.AddIfNotContains(messages);
Messages.AddIfNotContains(messages.OrderByDescending(m => m.LatestMessageDate));
}
}
24 changes: 9 additions & 15 deletions src/NuSocial/AppShell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
FlyoutItemIsVisible="False"
Route="start" />

<FlyoutItem Title="{loc:Translate Profile}" Icon="{x:Static fa:FontAwesomeIcons.User}">
<ShellContent ContentTemplate="{DataTemplate views:ProfileView}" Route="profile" />
</FlyoutItem>

<FlyoutItem Title="{loc:Translate Home}" Icon="{x:Static fa:FontAwesomeIcons.House}">
<ShellContent ContentTemplate="{DataTemplate views:MainView}" Route="home" />
</FlyoutItem>

<FlyoutItem Title="{loc:Translate Profile}" Icon="{x:Static fa:FontAwesomeIcons.User}">
<ShellContent ContentTemplate="{DataTemplate views:ProfileView}" Route="profile" />
</FlyoutItem>

<FlyoutItem Title="{loc:Translate Relays}" Icon="{x:Static fa:FontAwesomeIcons.Globe}">
<ShellContent ContentTemplate="{DataTemplate views:RelaysView}" Route="relays" />
</FlyoutItem>
Expand All @@ -45,18 +45,12 @@
</FlyoutItem>

<TabBar>
<Tab
Title="{loc:Translate Home}"
Icon="{x:Static fa:FontAwesomeIcons.House}"
Route="main">
<ShellContent ContentTemplate="{DataTemplate views:MainView}" />
<Tab Title="{loc:Translate Home}" Icon="{x:Static fa:FontAwesomeIcons.House}">
<ShellContent ContentTemplate="{DataTemplate views:MainView}" Route="main" />
</Tab>

<Tab
Title="{loc:Translate Messages}"
Icon="{x:Static fa:FontAwesomeIcons.Message}"
Route="messages">
<ShellContent ContentTemplate="{DataTemplate views:MessagesView}" />
<Tab Title="{loc:Translate Messages}" Icon="{x:Static fa:FontAwesomeIcons.Message}">
<ShellContent ContentTemplate="{DataTemplate views:MessagesView}" Route="messages" />
</Tab>
</TabBar>
<Shell.MenuItemTemplate>
Expand Down Expand Up @@ -141,7 +135,7 @@
</VisualState>
<VisualState x:Name="Selected">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="{StaticResource Primary}" />
<Setter Property="BackgroundColor" Value="Transparent" />
<Setter TargetName="IconLabel" Property="Label.TextColor" Value="White" />
<Setter TargetName="NameLabel" Property="Label.TextColor" Value="{StaticResource Gray300}" />
</VisualState.Setters>
Expand Down
13 changes: 6 additions & 7 deletions src/NuSocial/Controls/MessagePreviewItem.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,23 @@
xmlns:local="clr-namespace:NuSocial.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="root"
Margin="0,10"
mc:Ignorable="d">
<ContentView.Content>
<Grid
Margin="0"
Padding="20,0,20,20"
ColumnDefinitions="Auto,*,Auto"
ColumnSpacing="14"
ColumnSpacing="5"
RowDefinitions="Auto,Auto"
RowSpacing="6">
<local:ProfileImage
Grid.RowSpan="2"
Margin="0,2,0,0"
BorderSize="2"
CornerRadius="15"
HorizontalOptions="Center"
Size="50"
Source="{Binding Data.From.Picture.Url, Source={x:Reference root}}"
VerticalOptions="Center">
VerticalOptions="Start">
<local:ProfileImage.GestureRecognizers>
<TapGestureRecognizer Tapped="ProfileImage_Tapped" />
</local:ProfileImage.GestureRecognizers>
Expand All @@ -34,7 +33,7 @@
<!-- NAME -->
<Label
Grid.Column="1"
Margin="0,5,0,0"
Margin="0"
FontAttributes="Bold"
Text="{Binding Data.From.Name, Source={x:Reference root}}"
VerticalOptions="Center" />
Expand All @@ -50,7 +49,7 @@
FontSize="15"
Text="{x:Static fa:FontAwesomeIcons.Circle}"
TextColor="{DynamicResource OkColor}"
VerticalTextAlignment="Center" />
VerticalTextAlignment="Start" />
<Label
Grid.Column="1"
FontSize="{StaticResource BaseFontSize}"
Expand All @@ -74,7 +73,7 @@
Grid.Row="1"
Grid.Column="1"
Grid.ColumnSpan="2"
Margin="0,0,0,-15"
Margin="0,0,0,-10"
Style="{DynamicResource Horizontal1ptLineStyle}"
VerticalOptions="End" />
</Grid>
Expand Down
17 changes: 16 additions & 1 deletion src/NuSocial/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Maui.LifecycleEvents;
using Microsoft.Maui.Platform;
using Mopups.Hosting;
using NuSocial.Core.Threading;
using NuSocial.Localization;
Expand Down Expand Up @@ -63,7 +64,7 @@ public static MauiApp CreateMauiApp()
})
.ConfigureMopups()
.ConfigureContainer<ContainerBuilder>(new AbpAutofacServiceProviderFactory(GetAutofacContainerBuilder(builder.Services)));

HandleEntryHandler();
ConfigureFromConfigurationOptions(builder);

builder.Services.AddApplication<NuSocialModule>(options =>
Expand Down Expand Up @@ -95,6 +96,20 @@ public static MauiApp CreateMauiApp()
return app;
}

public static void HandleEntryHandler()
{
Microsoft.Maui.Handlers.EntryHandler.Mapper.AppendToMapping("NoUnderline", (handler, view) =>
{
#if ANDROID
handler.PlatformView.SetBackgroundColor(Colors.Transparent.ToPlatform());
#elif IOS || MACCATALYST
handler.PlatformView.BorderStyle = UIKit.UITextBorderStyle.None;
#elif WINDOWS
handler.PlatformView.FontWeight = Microsoft.UI.Text.FontWeights.Thin;
#endif
});
}

private static void SetupSerilog()
{
var flushInterval = new TimeSpan(0, 0, 1);
Expand Down
7 changes: 5 additions & 2 deletions src/NuSocial/Views/MainView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,18 @@
<Grid
ColumnDefinitions="Auto,*"
HeightRequest="44"
HorizontalOptions="End"
HorizontalOptions="Center"
VerticalOptions="Center">
<Label
FontAttributes="Bold"
FontSize="Large"
HorizontalTextAlignment="Center"
Text="{Binding Title}"
VerticalTextAlignment="Center" />
<HorizontalStackLayout Grid.Column="1" Padding="6">
<HorizontalStackLayout
Grid.Column="1"
Padding="6"
HorizontalOptions="End">
<local:IconButton
Clicked="IconButton_Clicked"
IconColor="{StaticResource White}"
Expand Down
2 changes: 2 additions & 0 deletions src/NuSocial/Views/MessagesView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
Shell.TabBarIsVisible="True">
<Grid RowDefinitions="Auto,*">
<SearchBar
Margin="0,0,0,10"
IsSpellCheckEnabled="False"
IsTextPredictionEnabled="False"
Keyboard="Text"
Expand All @@ -32,6 +33,7 @@
</SearchBar>
<RefreshView
Grid.Row="1"
BackgroundColor="Transparent"
Command="{Binding RefreshCommand}"
IsRefreshing="{Binding IsBusy}">
<CollectionView
Expand Down
10 changes: 5 additions & 5 deletions src/NuSocial/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Analytics": {
"AppCenterKey": ""
}
}
{
"Analytics": {
"AppCenterKey": "$ANALYTICS_KEY"
}
}

0 comments on commit ed48ccb

Please sign in to comment.