Fix issues with account image being stretched

This commit is contained in:
Rizwan Mohamed Ibrahim 2020-07-08 15:13:10 +05:30
parent ea3149d5bc
commit 8fb95f7900
No known key found for this signature in database
GPG Key ID: D5BEE468D448BCC5
2 changed files with 34 additions and 15 deletions

View File

@ -13,17 +13,23 @@ struct AccountHeaderImageView: View {
var image: RSImage var image: RSImage
var body: some View { var body: some View {
Image(rsImage: image) HStack(alignment: .center) {
.resizable() Image(rsImage: image)
.aspectRatio(1, contentMode: .fit) .resizable()
.frame(height: 48, alignment: .center) .scaledToFit()
.padding() .frame(height: 48, alignment: .center)
.padding()
}
} }
} }
struct AccountHeaderImageView_Previews: PreviewProvider { struct AccountHeaderImageView_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
AccountHeaderImageView(image: AppAssets.image(for: .onMyMac)!) Group {
AccountHeaderImageView(image: AppAssets.image(for: .onMyMac)!)
AccountHeaderImageView(image: AppAssets.image(for: .feedbin)!)
AccountHeaderImageView(image: AppAssets.accountLocalPadImage)
}
} }
} }

View File

@ -17,8 +17,8 @@ struct SettingsAccountLabelView: View {
HStack { HStack {
Image(rsImage: accountImage!) Image(rsImage: accountImage!)
.resizable() .resizable()
.aspectRatio(1, contentMode: .fit) .scaledToFit()
.frame(height: 32) .frame(width: 32, height: 32)
Text(verbatim: accountLabel).font(.title) Text(verbatim: accountLabel).font(.title)
} }
.foregroundColor(.primary).padding(4.0) .foregroundColor(.primary).padding(4.0)
@ -27,10 +27,23 @@ struct SettingsAccountLabelView: View {
struct SettingsAccountLabelView_Previews: PreviewProvider { struct SettingsAccountLabelView_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
SettingsAccountLabelView( List {
accountImage: AppAssets.image(for: .onMyMac), SettingsAccountLabelView(
accountLabel: "On My Device" accountImage: AppAssets.image(for: .onMyMac),
) accountLabel: "On My Device"
.previewLayout(.fixed(width: 300, height: 44)) )
SettingsAccountLabelView(
accountImage: AppAssets.image(for: .feedbin),
accountLabel: "Feedbin"
)
SettingsAccountLabelView(
accountImage: AppAssets.accountLocalPadImage,
accountLabel: "On My iPad"
)
SettingsAccountLabelView(
accountImage: AppAssets.accountLocalPhoneImage,
accountLabel: "On My iPhone"
)
}
} }
} }