|
|
|
|
|
|
using Unity.UIWidgets.ui; |
|
|
|
using Unity.UIWidgets.widgets; |
|
|
|
using Color = Unity.UIWidgets.ui.Color; |
|
|
|
using FontStyle = Unity.UIWidgets.ui.FontStyle; |
|
|
|
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|
|
|
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|
|
|
|
|
|
|
namespace UIWidgetsSample |
|
|
|
{ |
|
|
|
|
|
|
"lottieflow-social-networks-16-7-000000-easey.json", |
|
|
|
}; |
|
|
|
|
|
|
|
public static List<string> localImages = new List<string>() |
|
|
|
{ |
|
|
|
"heroSample/cube2.jpeg", |
|
|
|
"heroSample/sphere2.jpeg", |
|
|
|
"heroSample/capture2.jpeg", |
|
|
|
"heroSample/cylinder2.jpeg", |
|
|
|
}; |
|
|
|
|
|
|
|
public static List<string> imageUrls = new List<string>() |
|
|
|
{ |
|
|
|
"https://cdn.pixabay.com/photo/2016/10/21/14/50/plouzane-1758197_960_720.jpg", |
|
|
|
|
|
|
internal static Random random = new Random(); |
|
|
|
|
|
|
|
public static bool UseImage = true; |
|
|
|
public static bool UseLocalImage = false; |
|
|
|
public static bool UseAmountSlider = false; |
|
|
|
|
|
|
|
public static T RandomSelect<T>(this List<T> a) |
|
|
|
|
|
|
{ |
|
|
|
if (Utils.UseImage) |
|
|
|
{ |
|
|
|
_tiles.Add( |
|
|
|
new ImageTile( |
|
|
|
Utils.colors.RandomSelect(), |
|
|
|
Utils.imageUrls.RandomSelect() |
|
|
|
) |
|
|
|
); |
|
|
|
if (Utils.UseLocalImage) |
|
|
|
{ |
|
|
|
_tiles.Add( |
|
|
|
new ImageTile( |
|
|
|
Utils.colors.RandomSelect(), |
|
|
|
Utils.localImages.RandomSelect(), |
|
|
|
true |
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_tiles.Add( |
|
|
|
new ImageTile( |
|
|
|
Utils.colors.RandomSelect(), |
|
|
|
Utils.imageUrls.RandomSelect() |
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
internal class ImageTile : StatefulWidget |
|
|
|
{ |
|
|
|
internal ImageTile(Color backgroundColor, string path) |
|
|
|
internal ImageTile(Color backgroundColor, string path, bool local = false) |
|
|
|
this.local = local; |
|
|
|
public readonly bool local; |
|
|
|
|
|
|
|
public override State createState() |
|
|
|
{ |
|
|
|
|
|
|
{ |
|
|
|
public override Widget build(BuildContext context) |
|
|
|
{ |
|
|
|
if (widget.local) |
|
|
|
{ |
|
|
|
return new Container( |
|
|
|
color: widget.backgroundColor, |
|
|
|
child: Image.file( |
|
|
|
widget.path, |
|
|
|
fit: BoxFit.cover |
|
|
|
) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
child: new InkWell( |
|
|
|
onTap: () => { }, |
|
|
|
child: Image.network( |
|
|
|
child: Image.network( |
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|