Skip to content

Commit

Permalink
feat: Implemented FileSavePicker on MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
snickler committed Oct 11, 2020
1 parent a7b8e80 commit cfecbe8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/Uno.UWP/Storage/Pickers/FileSavePicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public partial class FileSavePicker

public string CommitButtonText { get; set; }

public IDictionary<string, IList<string>> FileTypeChoices { get; set; } = new Dictionary<string, IList<string>>();
public IDictionary<string, IList<string>> FileTypeChoices { get; } = new Dictionary<string, IList<string>>();
}
}
5 changes: 2 additions & 3 deletions src/Uno.UWP/Storage/Pickers/FileSavePicker.macOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ private async Task<StorageFile> PickFileTaskAsync()
var savePicker = new NSSavePanel();
savePicker.DirectoryUrl = new NSUrl(GetStartPath(), true);
savePicker.AllowedFileTypes = GetFileTypes();
if(SuggestedFileName != null)
if (SuggestedFileName != null)
{
savePicker.NameFieldStringValue = SuggestedFileName;
}
Expand All @@ -43,12 +43,11 @@ private string GetStartPath()
PickerLocationId.PicturesLibrary => Environment.SpecialFolder.MyPictures,
PickerLocationId.VideosLibrary => Environment.SpecialFolder.MyVideos,
_ => Environment.SpecialFolder.Personal

};

return Environment.GetFolderPath(specialFolder);
}

private string[] GetFileTypes() => FileTypeChoices.SelectMany(x => x.Value.Select(val=>val.TrimStart(new[] { '.' }))).ToArray();
private string[] GetFileTypes() => FileTypeChoices.SelectMany(x => x.Value.Select(val => val.TrimStart(new[] { '.' }))).ToArray();
}
}
27 changes: 2 additions & 25 deletions src/Uno.UWP/Storage/Pickers/PickerLocationId.cs
Original file line number Diff line number Diff line change
@@ -1,39 +1,16 @@
namespace Windows.Storage.Pickers
{


public enum PickerLocationId
{

DocumentsLibrary,


ComputerFolder,


Desktop,


Downloads,


HomeGroup,


MusicLibrary,


PicturesLibrary,


VideosLibrary,


Objects3D,


Unspecified,

Unspecified
}

}
}

0 comments on commit cfecbe8

Please sign in to comment.