A Go library for adding fancy additions to the filesystem. This is useful for file managers and other tools that have a graphical representation of a users files and folders.
fancyfs.FileIcon is a fancy icon for files that draws overlays and previews when possible.
Folders are overlaid with their artwork and image files show a preview, loaded in the background and cached.
icon := fancyfs.NewFileIcon(uri)
// later, such as when a list item is reused
icon.SetURI(other)The functions below provide the same details if you would like to draw them yourself.
This over image can be placed over a folder or other item indicating the type of content in a fancy folder.
over := &canvas.Image{}
if ff, _ := fancyfs.DetailsForFolder(folderURI); ff != nil {
if ff.BackgroundURI != nil {
over.File = ff.BackgroundURI.Path()
}
if ff.BackgroundResource != nil {
over.Resource = theme.NewColoredResource(ff.BackgroundResource, theme.ColorNameBackground)
}
s.over.FillMode = ff.BackgroundFill
}Image files have a small preview that can be shown in place of their icon.
Loading is done in the background, so ask again once loaded is called.
preview := &canvas.Image{FillMode: canvas.ImageFillContain}
var show func()
show = func() {
ff, err := fancyfs.DetailsForFileAsync(fileURI, func() { fyne.Do(show) })
if err != nil {
return // fancyfs.ErrLoading for now, or fancyfs.ErrNoMetadata if there is no preview
}
preview.Image = ff.PreviewImage // raster images
preview.Resource = ff.PreviewResource // vector images
preview.Refresh()
}
show()