mirror of
https://github.com/bitwarden/mobile
synced 2025-12-11 05:43:30 +00:00
Removed grouping from Settings to fix a crash on iOS 15.4
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Bit.App.Pages
|
||||||
|
{
|
||||||
|
public interface ISettingsPageListItem
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -82,8 +82,26 @@
|
|||||||
</controls:ExtendedStackLayout>
|
</controls:ExtendedStackLayout>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|
||||||
|
<DataTemplate
|
||||||
|
x:Key="headerTemplate"
|
||||||
|
x:DataType="pages:SettingsPageHeaderListItem">
|
||||||
|
<StackLayout
|
||||||
|
Padding="0" Spacing="0" VerticalOptions="FillAndExpand"
|
||||||
|
StyleClass="list-row-header-container, list-row-header-container-platform">
|
||||||
|
<BoxView
|
||||||
|
StyleClass="list-section-separator-top, list-section-separator-top-platform" />
|
||||||
|
<StackLayout StyleClass="list-row-header, list-row-header-platform">
|
||||||
|
<Label
|
||||||
|
Text="{Binding Title}"
|
||||||
|
StyleClass="list-header, list-header-platform" />
|
||||||
|
</StackLayout>
|
||||||
|
<BoxView StyleClass="list-section-separator-bottom, list-section-separator-bottom-platform" />
|
||||||
|
</StackLayout>
|
||||||
|
</DataTemplate>
|
||||||
|
|
||||||
<pages:SettingsPageListItemSelector
|
<pages:SettingsPageListItemSelector
|
||||||
x:Key="listItemDataTemplateSelector"
|
x:Key="listItemDataTemplateSelector"
|
||||||
|
HeaderTemplate="{StaticResource headerTemplate}"
|
||||||
RegularTemplate="{StaticResource regularTemplate}"
|
RegularTemplate="{StaticResource regularTemplate}"
|
||||||
TimePickerTemplate="{StaticResource timePickerTemplate}" />
|
TimePickerTemplate="{StaticResource timePickerTemplate}" />
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
@@ -93,27 +111,8 @@
|
|||||||
ItemsSource="{Binding GroupedItems}"
|
ItemsSource="{Binding GroupedItems}"
|
||||||
VerticalOptions="FillAndExpand"
|
VerticalOptions="FillAndExpand"
|
||||||
ItemTemplate="{StaticResource listItemDataTemplateSelector}"
|
ItemTemplate="{StaticResource listItemDataTemplateSelector}"
|
||||||
IsGrouped="True"
|
|
||||||
SelectionMode="Single"
|
SelectionMode="Single"
|
||||||
SelectionChanged="RowSelected"
|
SelectionChanged="RowSelected"
|
||||||
StyleClass="list, list-platform">
|
StyleClass="list, list-platform" />
|
||||||
|
|
||||||
<CollectionView.GroupHeaderTemplate>
|
|
||||||
<DataTemplate x:DataType="pages:SettingsPageListGroup">
|
|
||||||
<StackLayout
|
|
||||||
Padding="0" Spacing="0" VerticalOptions="FillAndExpand"
|
|
||||||
StyleClass="list-row-header-container, list-row-header-container-platform">
|
|
||||||
<BoxView
|
|
||||||
StyleClass="list-section-separator-top, list-section-separator-top-platform" />
|
|
||||||
<StackLayout StyleClass="list-row-header, list-row-header-platform">
|
|
||||||
<Label
|
|
||||||
Text="{Binding Name}"
|
|
||||||
StyleClass="list-header, list-header-platform" />
|
|
||||||
</StackLayout>
|
|
||||||
<BoxView StyleClass="list-section-separator-bottom, list-section-separator-bottom-platform" />
|
|
||||||
</StackLayout>
|
|
||||||
</DataTemplate>
|
|
||||||
</CollectionView.GroupHeaderTemplate>
|
|
||||||
</controls:ExtendedCollectionView>
|
|
||||||
|
|
||||||
</pages:BaseContentPage>
|
</pages:BaseContentPage>
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
namespace Bit.App.Pages
|
||||||
|
{
|
||||||
|
public class SettingsPageHeaderListItem : ISettingsPageListItem
|
||||||
|
{
|
||||||
|
public SettingsPageHeaderListItem(string title)
|
||||||
|
{
|
||||||
|
Title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Title { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using Bit.App.Resources;
|
using Bit.App.Resources;
|
||||||
using Bit.App.Utilities;
|
using Bit.App.Utilities;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
|
|
||||||
namespace Bit.App.Pages
|
namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
public class SettingsPageListItem
|
public class SettingsPageListItem : ISettingsPageListItem
|
||||||
{
|
{
|
||||||
public string Icon { get; set; }
|
public string Icon { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|||||||
@@ -4,21 +4,19 @@ namespace Bit.App.Pages
|
|||||||
{
|
{
|
||||||
public class SettingsPageListItemSelector : DataTemplateSelector
|
public class SettingsPageListItemSelector : DataTemplateSelector
|
||||||
{
|
{
|
||||||
|
public DataTemplate HeaderTemplate { get; set; }
|
||||||
public DataTemplate RegularTemplate { get; set; }
|
public DataTemplate RegularTemplate { get; set; }
|
||||||
public DataTemplate TimePickerTemplate { get; set; }
|
public DataTemplate TimePickerTemplate { get; set; }
|
||||||
|
|
||||||
protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
|
protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
|
||||||
{
|
{
|
||||||
|
if (item is SettingsPageHeaderListItem)
|
||||||
|
{
|
||||||
|
return HeaderTemplate;
|
||||||
|
}
|
||||||
if (item is SettingsPageListItem listItem)
|
if (item is SettingsPageListItem listItem)
|
||||||
{
|
{
|
||||||
if (listItem.ShowTimeInput)
|
return listItem.ShowTimeInput ? TimePickerTemplate : RegularTemplate;
|
||||||
{
|
|
||||||
return TimePickerTemplate;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return RegularTemplate;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,11 +83,11 @@ namespace Bit.App.Pages
|
|||||||
_keyConnectorService = ServiceContainer.Resolve<IKeyConnectorService>("keyConnectorService");
|
_keyConnectorService = ServiceContainer.Resolve<IKeyConnectorService>("keyConnectorService");
|
||||||
_clipboardService = ServiceContainer.Resolve<IClipboardService>("clipboardService");
|
_clipboardService = ServiceContainer.Resolve<IClipboardService>("clipboardService");
|
||||||
|
|
||||||
GroupedItems = new ObservableRangeCollection<SettingsPageListGroup>();
|
GroupedItems = new ObservableRangeCollection<ISettingsPageListItem>();
|
||||||
PageTitle = AppResources.Settings;
|
PageTitle = AppResources.Settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableRangeCollection<SettingsPageListGroup> GroupedItems { get; set; }
|
public ObservableRangeCollection<ISettingsPageListItem> GroupedItems { get; set; }
|
||||||
|
|
||||||
public async Task InitAsync()
|
public async Task InitAsync()
|
||||||
{
|
{
|
||||||
@@ -409,8 +409,6 @@ namespace Bit.App.Pages
|
|||||||
|
|
||||||
public void BuildList()
|
public void BuildList()
|
||||||
{
|
{
|
||||||
GroupedItems.Clear();
|
|
||||||
|
|
||||||
var doUpper = Device.RuntimePlatform != Device.Android;
|
var doUpper = Device.RuntimePlatform != Device.Android;
|
||||||
var autofillItems = new List<SettingsPageListItem>();
|
var autofillItems = new List<SettingsPageListItem>();
|
||||||
if (Device.RuntimePlatform == Device.Android)
|
if (Device.RuntimePlatform == Device.Android)
|
||||||
@@ -512,7 +510,9 @@ namespace Bit.App.Pages
|
|||||||
new SettingsPageListItem { Name = AppResources.RateTheApp },
|
new SettingsPageListItem { Name = AppResources.RateTheApp },
|
||||||
new SettingsPageListItem { Name = AppResources.DeleteAccount }
|
new SettingsPageListItem { Name = AppResources.DeleteAccount }
|
||||||
};
|
};
|
||||||
GroupedItems.AddRange(new List<SettingsPageListGroup>
|
|
||||||
|
// TODO: improve this. Leaving this as is to reduce error possibility on the hotfix.
|
||||||
|
var settingsListGroupItems = new List<SettingsPageListGroup>()
|
||||||
{
|
{
|
||||||
new SettingsPageListGroup(autofillItems, AppResources.Autofill, doUpper, true),
|
new SettingsPageListGroup(autofillItems, AppResources.Autofill, doUpper, true),
|
||||||
new SettingsPageListGroup(manageItems, AppResources.Manage, doUpper),
|
new SettingsPageListGroup(manageItems, AppResources.Manage, doUpper),
|
||||||
@@ -520,7 +520,14 @@ namespace Bit.App.Pages
|
|||||||
new SettingsPageListGroup(accountItems, AppResources.Account, doUpper),
|
new SettingsPageListGroup(accountItems, AppResources.Account, doUpper),
|
||||||
new SettingsPageListGroup(toolsItems, AppResources.Tools, doUpper),
|
new SettingsPageListGroup(toolsItems, AppResources.Tools, doUpper),
|
||||||
new SettingsPageListGroup(otherItems, AppResources.Other, doUpper)
|
new SettingsPageListGroup(otherItems, AppResources.Other, doUpper)
|
||||||
});
|
};
|
||||||
|
var settingsItems = new List<ISettingsPageListItem>();
|
||||||
|
foreach (var itemGroup in settingsListGroupItems)
|
||||||
|
{
|
||||||
|
settingsItems.Add(new SettingsPageHeaderListItem(itemGroup.Name));
|
||||||
|
settingsItems.AddRange(itemGroup);
|
||||||
|
}
|
||||||
|
GroupedItems.ReplaceRange(settingsItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IncludeLinksWithSubscriptionInfo()
|
private bool IncludeLinksWithSubscriptionInfo()
|
||||||
|
|||||||
Reference in New Issue
Block a user