This commit is contained in:
SunboX 2017-08-07 23:07:21 +02:00
Родитель b6c6b6eefe
Коммит b536c6fd43
7 изменённых файлов: 99 добавлений и 29 удалений

Просмотреть файл

@ -315,7 +315,7 @@ namespace NextcloudApp
{
var task = base.OnSuspendingApplicationAsync();
// Stop Background Sync Tasks
List<FolderSyncInfo> activeSyncs = SyncDbUtils.GetActiveSyncInfos();
var activeSyncs = SyncDbUtils.GetActiveSyncInfos();
foreach (var fsi in activeSyncs)
{
ToastNotificationService.ShowSyncSuspendedNotification(fsi);
@ -374,11 +374,22 @@ namespace NextcloudApp
}
else
{
var fileInfoPageParameters = new FileInfoPageParameters
IPageParameters resourceInfoPageParameters = null;
if (pageParameters?.PageTarget == PageToken.DirectoryList)
{
ResourceInfo = pageParameters?.ResourceInfo
};
CheckSettingsAndContinue(pageParameters?.PageTarget ?? PageToken.DirectoryList, fileInfoPageParameters);
resourceInfoPageParameters = new DirectoryListPageParameters
{
ResourceInfo = pageParameters?.ResourceInfo
};
}
else if (pageParameters?.PageTarget == PageToken.FileInfo)
{
resourceInfoPageParameters = new FileInfoPageParameters
{
ResourceInfo = pageParameters?.ResourceInfo
};
}
CheckSettingsAndContinue(pageParameters?.PageTarget ?? PageToken.DirectoryList, resourceInfoPageParameters);
}
return Task.FromResult(true);
}

Просмотреть файл

@ -0,0 +1,9 @@
using NextcloudClient.Types;
namespace NextcloudApp.Models
{
public class DirectoryListPageParameters : PageParameters<DirectoryListPageParameters>
{
public ResourceInfo ResourceInfo { get; set; }
}
}

Просмотреть файл

@ -153,6 +153,7 @@
<Compile Include="Converter\SynchronizeThisFolderToTextConverter.cs" />
<Compile Include="Converter\SyncInfoStoragePathConverter.cs" />
<Compile Include="Models\ConflictSolution.cs" />
<Compile Include="Models\DirectoryListPageParameters.cs" />
<Compile Include="Models\FolderSyncInfo.cs" />
<Compile Include="Models\IPageParameters.cs" />
<Compile Include="Models\MoveFileOrFolderPageParameters.cs" />

Просмотреть файл

@ -599,5 +599,36 @@ namespace NextcloudApp.Services
await client.ToggleFavorite(resourceInfo);
}
public void RebuildPathStackFromResourceInfo(ResourceInfo resourceInfo)
{
// remove all except root node
while (PathStack.Count > 1)
{
PathStack.RemoveAt(PathStack.Count - 1);
}
// get path array from resource info
var path = resourceInfo.Path.Split('/');
var newPath = string.Empty;
// register path
foreach (var p in path)
{
if (string.IsNullOrEmpty(p))
{
continue;
}
newPath += "/" + p;
PathStack.Add(new PathInfo
{
ResourceInfo = new ResourceInfo()
{
Name = p,
Path = newPath + "/"
}
});
}
}
}
}

Просмотреть файл

@ -1,6 +1,6 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:NextcloudApp">
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="MenuFlyoutIconItemStyle" TargetType="MenuFlyoutItem">
<Setter Property="Background" Value="Transparent"/>
@ -45,6 +45,12 @@
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="SymbolIcon">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledBaseMediumLowBrush}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="FontIcon">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledBaseMediumLowBrush}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="TextBlock">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledBaseMediumLowBrush}"/>
</ObjectAnimationUsingKeyFrames>
@ -74,20 +80,22 @@
</VisualStateManager.VisualStateGroups>
<StackPanel Orientation="Horizontal">
<SymbolIcon
Margin="0,0,12,0"
Symbol="{Binding Tag, RelativeSource={RelativeSource Mode=TemplatedParent}}"
Visibility="{Binding Tag, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource IsGlyphToVisibilityConverter}, ConverterParameter=true}"/>
x:Name="SymbolIcon"
Margin="0,0,12,0"
Symbol="{Binding Tag, RelativeSource={RelativeSource Mode=TemplatedParent}}"
Visibility="{Binding Tag, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource IsGlyphToVisibilityConverter}, ConverterParameter=true}"/>
<FontIcon
Margin="0,0,12,0"
Glyph="{Binding Tag, RelativeSource={RelativeSource Mode=TemplatedParent}}"
Visibility="{Binding Tag, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource IsGlyphToVisibilityConverter}}"/>
x:Name="FontIcon"
Margin="0,0,12,0"
Glyph="{Binding Tag, RelativeSource={RelativeSource Mode=TemplatedParent}}"
Visibility="{Binding Tag, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource IsGlyphToVisibilityConverter}}"/>
<TextBlock
x:Name="TextBlock"
Foreground="{TemplateBinding Foreground}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Text="{TemplateBinding Text}"
TextTrimming="Clip"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
x:Name="TextBlock"
Foreground="{TemplateBinding Foreground}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Text="{TemplateBinding Text}"
TextTrimming="Clip"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</StackPanel>
</Grid>
</ControlTemplate>

Просмотреть файл

@ -147,8 +147,7 @@ namespace NextcloudApp.ViewModels
StopSynchronizeFolderCommand = new RelayCommand(StopSynchronizeFolder);
StopSynchronizeThisFolderCommand = new RelayCommand(StopSynchronizeThisFolder);
MoveSelectedCommand = new RelayCommand(MoveSelected);
//PinToStartCommand = new DelegateCommand<object>(PinToStart, CanPinToStart);
PinToStartCommand = new DelegateCommand<object>(PinToStart);
PinToStartCommand = new DelegateCommand<object>(PinToStart, CanPinToStart);
ToggleFavoriteCommand = new RelayCommand(ToggleFavorite);
}
@ -156,6 +155,15 @@ namespace NextcloudApp.ViewModels
{
base.OnNavigatedTo(e, viewModelState);
Directory = DirectoryService.Instance;
var parameters = DirectoryListPageParameters.Deserialize(e.Parameter);
var resourceInfo = parameters?.ResourceInfo;
if (resourceInfo != null)
{
Directory.RebuildPathStackFromResourceInfo(resourceInfo);
}
_selectedPathIndex = Directory.PathStack.Count - 1;
_isNavigatingBack = false;
StartDirectoryListing();
@ -555,7 +563,7 @@ namespace NextcloudApp.ViewModels
return false;
}
var resourceInfo = (ResourceInfo) parameter;
return _tileService.IsTilePinned(resourceInfo);
return !_tileService.IsTilePinned(resourceInfo);
}
private void UploadFiles()

Просмотреть файл

@ -70,11 +70,6 @@ namespace NextcloudApp.ViewModels
{
base.OnNavigatedTo(e, viewModelState);
foreach(var path in Directory.PathStack)
{
PathStack.Add(path);
}
var parameters = FileInfoPageParameters.Deserialize(e.Parameter);
var resourceInfo = parameters?.ResourceInfo;
@ -83,6 +78,13 @@ namespace NextcloudApp.ViewModels
return;
}
Directory.RebuildPathStackFromResourceInfo(resourceInfo);
foreach (var path in Directory.PathStack)
{
PathStack.Add(path);
}
PathStack.Add(new PathInfo
{
ResourceInfo = resourceInfo
@ -339,7 +341,7 @@ namespace NextcloudApp.ViewModels
private bool CanPinToStart(object parameter)
{
return ResourceInfo != null && _tileService.IsTilePinned(ResourceInfo);
return ResourceInfo != null && !_tileService.IsTilePinned(ResourceInfo);
}
}
}