mirror of
https://github.com/awatertrevi/xamarin-neo4j.git
synced 2026-10-09 19:08:04 +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 <[email protected]>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
bdbf738fe3
commit
235cda85b8
@@ -5,16 +5,9 @@
|
|||||||
xmlns:fonts="clr-namespace:Xamarin.Neo4j.Fonts;assembly=Xamarin.Neo4j"
|
xmlns:fonts="clr-namespace:Xamarin.Neo4j.Fonts;assembly=Xamarin.Neo4j"
|
||||||
x:Class="Xamarin.Neo4j.Controls.ConnectionCell">
|
x:Class="Xamarin.Neo4j.Controls.ConnectionCell">
|
||||||
<Grid Padding="15, 10">
|
<Grid Padding="15, 10">
|
||||||
<Grid.ColumnDefinitions>
|
<StackLayout Spacing="2">
|
||||||
<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">
|
|
||||||
<Label Text="{Binding Name}" />
|
<Label Text="{Binding Name}" />
|
||||||
<Label Text="{Binding Host}" FontSize="Small" TextColor="{StaticResource SecondaryTextColor}" />
|
<Label Text="{Binding Host}" FontSize="Small" TextColor="{DynamicResource SecondaryTextColor}" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</Grid>
|
</Grid>
|
||||||
</ViewCell>
|
</ViewCell>
|
||||||
|
|||||||
@@ -15,21 +15,6 @@ namespace Xamarin.Neo4j.Controls
|
|||||||
public ConnectionCell()
|
public ConnectionCell()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
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:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
xmlns:fonts="clr-namespace:Xamarin.Neo4j.Fonts;assembly=Xamarin.Neo4j"
|
xmlns:fonts="clr-namespace:Xamarin.Neo4j.Fonts;assembly=Xamarin.Neo4j"
|
||||||
xmlns:controls="clr-namespace:Xamarin.Neo4j.Controls;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"
|
x:Name="connectionsPage"
|
||||||
Title="Connections">
|
Title="PocketGraph">
|
||||||
<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>
|
|
||||||
|
|
||||||
<ContentPage.ToolbarItems>
|
<ContentPage.ToolbarItems>
|
||||||
<ToolbarItem Command="{Binding Commands[StartSession]}">
|
<ToolbarItem Text="Settings" Order="Secondary" Command="{Binding Commands[OpenSettings]}" />
|
||||||
<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>
|
|
||||||
</ContentPage.ToolbarItems>
|
</ContentPage.ToolbarItems>
|
||||||
|
|
||||||
<ContentPage.Content>
|
<ContentPage.Content>
|
||||||
<Grid>
|
<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>
|
<ListView.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<controls:ConnectionCell IsActive="{Binding ., Converter={StaticResource isActiveConnection}}">
|
<controls:ConnectionCell>
|
||||||
<controls:ConnectionCell.ContextActions>
|
<controls:ConnectionCell.ContextActions>
|
||||||
<MenuItem Text="Edit" Command="{Binding BindingContext.Commands[EditConnectionString], Source={x:Reference connectionsPage}}" CommandParameter="{Binding .}" />
|
<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" />
|
<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}"
|
<Label Text="{x:Static fonts:FontAwesomeSolid.Server}"
|
||||||
FontFamily="{StaticResource FontAwesomeSolid}"
|
FontFamily="{StaticResource FontAwesomeSolid}"
|
||||||
FontSize="48"
|
FontSize="48"
|
||||||
TextColor="{StaticResource SecondaryTextColor}"
|
TextColor="{DynamicResource SecondaryTextColor}"
|
||||||
HorizontalOptions="Center" />
|
HorizontalOptions="Center" />
|
||||||
<Label Text="No connections"
|
<Label Text="No connections"
|
||||||
FontSize="18"
|
FontSize="18"
|
||||||
FontAttributes="Bold"
|
FontAttributes="Bold"
|
||||||
TextColor="{StaticResource SecondaryTextColor}"
|
TextColor="{DynamicResource SecondaryTextColor}"
|
||||||
HorizontalOptions="Center" />
|
HorizontalOptions="Center" />
|
||||||
<Label Text="Tap + to add a connection"
|
<Label Text="Tap + to add a connection"
|
||||||
FontSize="14"
|
FontSize="14"
|
||||||
TextColor="{StaticResource SecondaryTextColor}"
|
TextColor="{DynamicResource SecondaryTextColor}"
|
||||||
HorizontalOptions="Center" />
|
HorizontalOptions="Center" />
|
||||||
</StackLayout>
|
</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>
|
</Grid>
|
||||||
</ContentPage.Content>
|
</ContentPage.Content>
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
|
|||||||
@@ -26,14 +26,25 @@ namespace Xamarin.Neo4j.Pages
|
|||||||
|
|
||||||
protected override void OnAppearing()
|
protected override void OnAppearing()
|
||||||
{
|
{
|
||||||
|
App.ThemeChanged += OnThemeChanged;
|
||||||
ViewModel.LoadConnectionStrings();
|
ViewModel.LoadConnectionStrings();
|
||||||
|
|
||||||
base.OnAppearing();
|
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();
|
LoadConnectionStrings();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
Commands.Add("StartSession", new Command(async () =>
|
Commands.Add("OpenSettings", new Command(async () =>
|
||||||
{
|
{
|
||||||
if (ConnectionStringManager.ActiveConnectionString == null)
|
await Navigation.PushAsync(new SettingsPage());
|
||||||
{
|
|
||||||
await Application.Current.MainPage.DisplayAlert("", "Please select a connection before starting a session.", "OK");
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await Navigation.PushAsync(new SessionPage(ConnectionStringManager.ActiveConnectionString));
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,11 +67,11 @@ namespace Xamarin.Neo4j.ViewModels
|
|||||||
ConnectionStrings = await ConnectionStringManager.GetConnectionStrings();
|
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();
|
LoadConnectionStrings();
|
||||||
|
await Navigation.PushAsync(new SessionPage(connectionString));
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Bindable Properties
|
#region Bindable Properties
|
||||||
|
|||||||
Reference in New Issue
Block a user