Make inspector add a background for small dark images

This commit is contained in:
Maurice Parker 2019-09-30 02:45:33 -05:00
parent 2756da00e1
commit 8d0bfd9b47
1 changed files with 18 additions and 2 deletions

View File

@ -13,6 +13,7 @@ import Account
struct FeedInspectorView : View {
@ObservedObject var viewModel: ViewModel
@Environment(\.colorScheme) private var colorScheme: ColorScheme
@Environment(\.viewController) private var viewController: UIViewController?
var body: some View {
@ -22,9 +23,24 @@ struct FeedInspectorView : View {
HStack {
Spacer()
if self.viewModel.image.size.width < 32 || self.viewModel.image.size.height < 32 {
Image(uiImage: self.viewModel.image).resizable().frame(width: 24.0, height: 24.0).cornerRadius(2.0)
if colorScheme == .dark && self.viewModel.image.isDark() {
ZStack {
Color(AppAssets.avatarBackgroundColor)
Image(uiImage: self.viewModel.image).resizable()
}
.frame(width: 24.0, height: 24.0)
.cornerRadius(2.0)
} else {
Image(uiImage: self.viewModel.image)
.resizable()
.frame(width: 24.0, height: 24.0)
.cornerRadius(2.0)
}
} else {
Image(uiImage: self.viewModel.image).resizable().frame(width: 48.0, height: 48.0).cornerRadius(5.0)
Image(uiImage: self.viewModel.image)
.resizable()
.frame(width: 48.0, height: 48.0)
.cornerRadius(5.0)
}
Spacer()
}) {