mirror of
https://github.com/awatertrevi/xamarin-neo4j.git
synced 2026-09-22 09:05:29 +00:00
Connections: remove active indicator dot, fix theme refresh
- Remove green dot IsActive indicator from ConnectionCell (no longer needed) - ConnectionsPage subscribes to App.ThemeChanged and reloads list on switch - Simplify ConnectionCell to single StackLayout (no converter dependency) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,16 +5,9 @@
|
||||
xmlns:fonts="clr-namespace:Xamarin.Neo4j.Fonts;assembly=Xamarin.Neo4j"
|
||||
x:Class="Xamarin.Neo4j.Controls.ConnectionCell">
|
||||
<Grid Padding="15, 10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Grid.Column="0" x:Name="isActiveIndicator" Text="{x:Static fonts:FontAwesomeSolid.Circle}" FontFamily="{StaticResource FontAwesomeSolid}" VerticalOptions="Center" TextColor="#34C759" Margin="0 ,0, 7.5, 0"/>
|
||||
|
||||
<StackLayout Grid.Column="1" Spacing="2">
|
||||
<StackLayout Spacing="2">
|
||||
<Label Text="{Binding Name}" />
|
||||
<Label Text="{Binding Host}" FontSize="Small" TextColor="{StaticResource SecondaryTextColor}" />
|
||||
<Label Text="{Binding Host}" FontSize="Small" TextColor="{DynamicResource SecondaryTextColor}" />
|
||||
</StackLayout>
|
||||
</Grid>
|
||||
</ViewCell>
|
||||
|
||||
@@ -15,21 +15,6 @@ namespace Xamarin.Neo4j.Controls
|
||||
public ConnectionCell()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
isActiveIndicator.SetBinding(VisualElement.IsVisibleProperty, new Binding(nameof(IsActive), source: this));
|
||||
}
|
||||
|
||||
#region Bindable Properties
|
||||
|
||||
public bool IsActive
|
||||
{
|
||||
get => (bool)GetValue(IsActiveProperty);
|
||||
set => SetValue(IsActiveProperty, value);
|
||||
}
|
||||
|
||||
public static BindableProperty IsActiveProperty = BindableProperty.Create("IsActive", typeof(bool),
|
||||
typeof(ConnectionCell), false, BindingMode.OneWay);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,47 +4,20 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:fonts="clr-namespace:Xamarin.Neo4j.Fonts;assembly=Xamarin.Neo4j"
|
||||
xmlns:controls="clr-namespace:Xamarin.Neo4j.Controls;assembly=Xamarin.Neo4j"
|
||||
xmlns:converters="clr-namespace:Xamarin.Neo4j.Converters;assembly=Xamarin.Neo4j"
|
||||
x:Class="Xamarin.Neo4j.Pages.ConnectionsPage"
|
||||
x:Class="Xamarin.Neo4j.Pages.ConnectionsPage"
|
||||
x:Name="connectionsPage"
|
||||
Title="Connections">
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<converters:IsActiveConnectionConverter x:Key="isActiveConnection" />
|
||||
</ResourceDictionary>
|
||||
</ContentPage.Resources>
|
||||
|
||||
<ContentPage.IconImageSource>
|
||||
<FontImageSource
|
||||
FontFamily="{StaticResource FontAwesomeSolid}"
|
||||
Glyph="{x:Static fonts:FontAwesomeSolid.Server}"
|
||||
Size="20" />
|
||||
</ContentPage.IconImageSource>
|
||||
Title="PocketGraph">
|
||||
|
||||
<ContentPage.ToolbarItems>
|
||||
<ToolbarItem Command="{Binding Commands[StartSession]}">
|
||||
<ToolbarItem.IconImageSource>
|
||||
<FontImageSource
|
||||
FontFamily="{StaticResource FontAwesomeSolid}"
|
||||
Glyph="{x:Static fonts:FontAwesomeSolid.Terminal}" Size="20" />
|
||||
</ToolbarItem.IconImageSource>
|
||||
</ToolbarItem>
|
||||
|
||||
<ToolbarItem Command="{Binding Commands[AddConnection]}">
|
||||
<ToolbarItem.IconImageSource>
|
||||
<FontImageSource
|
||||
FontFamily="{StaticResource FontAwesomeSolid}"
|
||||
Glyph="{x:Static fonts:FontAwesomeSolid.PlusCircle}" Size="20" />
|
||||
</ToolbarItem.IconImageSource>
|
||||
</ToolbarItem>
|
||||
<ToolbarItem Text="Settings" Order="Secondary" Command="{Binding Commands[OpenSettings]}" />
|
||||
</ContentPage.ToolbarItems>
|
||||
|
||||
<ContentPage.Content>
|
||||
<Grid>
|
||||
<ListView ItemsSource="{Binding ConnectionStrings}" HasUnevenRows="True" SelectionMode="None" ItemTapped="SetActive" IsVisible="{Binding HasItems}">
|
||||
<ListView ItemsSource="{Binding ConnectionStrings}" HasUnevenRows="True" SelectionMode="None" ItemTapped="OpenSession" IsVisible="{Binding HasItems}">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<controls:ConnectionCell IsActive="{Binding ., Converter={StaticResource isActiveConnection}}">
|
||||
<controls:ConnectionCell>
|
||||
<controls:ConnectionCell.ContextActions>
|
||||
<MenuItem Text="Edit" Command="{Binding BindingContext.Commands[EditConnectionString], Source={x:Reference connectionsPage}}" CommandParameter="{Binding .}" />
|
||||
<MenuItem Text="Delete" Command="{Binding BindingContext.Commands[DeleteConnectionString], Source={x:Reference connectionsPage}}" CommandParameter="{Binding .}" IsDestructive="true" />
|
||||
@@ -58,18 +31,30 @@
|
||||
<Label Text="{x:Static fonts:FontAwesomeSolid.Server}"
|
||||
FontFamily="{StaticResource FontAwesomeSolid}"
|
||||
FontSize="48"
|
||||
TextColor="{StaticResource SecondaryTextColor}"
|
||||
TextColor="{DynamicResource SecondaryTextColor}"
|
||||
HorizontalOptions="Center" />
|
||||
<Label Text="No connections"
|
||||
FontSize="18"
|
||||
FontAttributes="Bold"
|
||||
TextColor="{StaticResource SecondaryTextColor}"
|
||||
TextColor="{DynamicResource SecondaryTextColor}"
|
||||
HorizontalOptions="Center" />
|
||||
<Label Text="Tap + to add a connection"
|
||||
FontSize="14"
|
||||
TextColor="{StaticResource SecondaryTextColor}"
|
||||
TextColor="{DynamicResource SecondaryTextColor}"
|
||||
HorizontalOptions="Center" />
|
||||
</StackLayout>
|
||||
|
||||
<!-- FAB -->
|
||||
<Button Text="{x:Static fonts:FontAwesomeSolid.Plus}"
|
||||
FontFamily="{StaticResource FontAwesomeSolid}"
|
||||
FontSize="20"
|
||||
WidthRequest="56" HeightRequest="56"
|
||||
CornerRadius="28"
|
||||
BackgroundColor="{DynamicResource Accent}"
|
||||
TextColor="White"
|
||||
VerticalOptions="End" HorizontalOptions="End"
|
||||
Margin="0,0,16,16"
|
||||
Command="{Binding Commands[AddConnection]}" />
|
||||
</Grid>
|
||||
</ContentPage.Content>
|
||||
</ContentPage>
|
||||
|
||||
@@ -26,14 +26,25 @@ namespace Xamarin.Neo4j.Pages
|
||||
|
||||
protected override void OnAppearing()
|
||||
{
|
||||
App.ThemeChanged += OnThemeChanged;
|
||||
ViewModel.LoadConnectionStrings();
|
||||
|
||||
base.OnAppearing();
|
||||
}
|
||||
|
||||
private void SetActive(object sender, ItemTappedEventArgs e)
|
||||
protected override void OnDisappearing()
|
||||
{
|
||||
ViewModel.SetActiveConnectionString((Neo4jConnectionString)e.Item);
|
||||
App.ThemeChanged -= OnThemeChanged;
|
||||
base.OnDisappearing();
|
||||
}
|
||||
|
||||
private void OnThemeChanged(object sender, EventArgs e)
|
||||
{
|
||||
ViewModel.LoadConnectionStrings();
|
||||
}
|
||||
|
||||
private void OpenSession(object sender, ItemTappedEventArgs e)
|
||||
{
|
||||
ViewModel.OpenSession((Neo4jConnectionString)e.Item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,16 +50,9 @@ namespace Xamarin.Neo4j.ViewModels
|
||||
LoadConnectionStrings();
|
||||
}));
|
||||
|
||||
Commands.Add("StartSession", new Command(async () =>
|
||||
Commands.Add("OpenSettings", new Command(async () =>
|
||||
{
|
||||
if (ConnectionStringManager.ActiveConnectionString == null)
|
||||
{
|
||||
await Application.Current.MainPage.DisplayAlert("", "Please select a connection before starting a session.", "OK");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
await Navigation.PushAsync(new SessionPage(ConnectionStringManager.ActiveConnectionString));
|
||||
await Navigation.PushAsync(new SettingsPage());
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -74,11 +67,11 @@ namespace Xamarin.Neo4j.ViewModels
|
||||
ConnectionStrings = await ConnectionStringManager.GetConnectionStrings();
|
||||
}
|
||||
|
||||
public void SetActiveConnectionString(Neo4jConnectionString connectionString)
|
||||
public async void OpenSession(Neo4jConnectionString connectionString)
|
||||
{
|
||||
ConnectionStringManager.ActiveConnectionString = ConnectionStringManager.ActiveConnectionString?.Id == connectionString.Id ? null : connectionString;
|
||||
|
||||
ConnectionStringManager.ActiveConnectionString = connectionString;
|
||||
LoadConnectionStrings();
|
||||
await Navigation.PushAsync(new SessionPage(connectionString));
|
||||
}
|
||||
|
||||
#region Bindable Properties
|
||||
|
||||
Reference in New Issue
Block a user