Add top-right icon image, adjust colors of text and progress gauge

This commit is contained in:
Shawn 2023-10-19 11:47:10 -06:00
parent 0cff2e5ecc
commit 310dcd918b
2 changed files with 13 additions and 11 deletions

View File

@ -15,12 +15,12 @@ struct BgImage : View {
var entry: WonderousEntry var entry: WonderousEntry
var body: some View { var body: some View {
let image = bundle.appending(path: "/assets/images/widget/background-empty.jpg").path(); let image = bundle.appending(path: "/assets/images/widget/background-empty.jpg").path();
print(image) //print(image)
if let uiImage = UIImage(contentsOfFile: image) { if let uiImage = UIImage(contentsOfFile: image) {
let image = Image(uiImage: uiImage) let image = Image(uiImage: uiImage)
.resizable() .resizable()
.aspectRatio(contentMode: .fill) // Fill the entire view .aspectRatio(contentMode: .fill) // Fill the entire view
// .edgesIgnoringSafeArea(.all) // Ignore the safe area .edgesIgnoringSafeArea(.all) // Ignore the safe area
return AnyView(image) return AnyView(image)
} }
print("The image file could not be loaded") print("The image file could not be loaded")
@ -48,7 +48,7 @@ struct NetImage : View {
} }
struct GaugeProgressStyle: ProgressViewStyle { struct GaugeProgressStyle: ProgressViewStyle {
let color:Color
func makeBody(configuration: Configuration) -> some View { func makeBody(configuration: Configuration) -> some View {
let fractionCompleted = configuration.fractionCompleted ?? 0 let fractionCompleted = configuration.fractionCompleted ?? 0
@ -57,7 +57,7 @@ struct GaugeProgressStyle: ProgressViewStyle {
.stroke(.gray, style: StrokeStyle(lineWidth: 2)) .stroke(.gray, style: StrokeStyle(lineWidth: 2))
Circle() Circle()
.trim(from: 0, to: fractionCompleted) .trim(from: 0, to: fractionCompleted)
.stroke(.red, style: StrokeStyle(lineWidth: 4, lineCap: .round)) .stroke(color, style: StrokeStyle(lineWidth: 4, lineCap: .round))
.rotationEffect(.degrees(90)) .rotationEffect(.degrees(90))
} }
} }

View File

@ -10,16 +10,18 @@ struct WonderousWidgetView : View {
let showTitle = family == .systemLarge let showTitle = family == .systemLarge
let showIcon = family != .systemSmall let showIcon = family != .systemSmall
let showTitleAndDesc = family != .systemSmall let showTitleAndDesc = family != .systemSmall
let textColor:Color = .pink let accentColor:Color = Color("AccentColor")
let progress = 7.0 / 32.0; let progress = 7.0 / 32.0;
let image = bundle.appending(path: "/assets/images/widget/wonderous-icon.png").path();
let content = VStack{ let content = VStack{
HStack { HStack {
if(showTitle) { if(showTitle) {
Text("Collection").foregroundColor(textColor) Text("Collection").foregroundColor(accentColor)
} }
Spacer(); Spacer();
if(showIcon) { if(showIcon || true) {
Text("1").foregroundColor(textColor) Image(uiImage: UIImage(contentsOfFile: image)!)
.resizable().scaledToFit().frame(height: 24)
} }
} }
Spacer(); Spacer();
@ -28,7 +30,7 @@ struct WonderousWidgetView : View {
VStack(alignment: .leading){ VStack(alignment: .leading){
Text("Wonderous") Text("Wonderous")
.font(.system(size: 22)) .font(.system(size: 22))
.foregroundColor(textColor); .foregroundColor(accentColor);
Text("Search for hidden artifacts") Text("Search for hidden artifacts")
.font(.system(size: 15)) .font(.system(size: 15))
.foregroundColor(Color("GreyMediumColor")); .foregroundColor(Color("GreyMediumColor"));
@ -38,10 +40,10 @@ struct WonderousWidgetView : View {
ZStack{ ZStack{
ProgressView(value: progress) ProgressView(value: progress)
.progressViewStyle( .progressViewStyle(
GaugeProgressStyle() GaugeProgressStyle(color: accentColor)
) )
.frame(width: 48, height: 48) .frame(width: 48, height: 48)
Text("\(Int(progress * 100))%").font(.system(size: 12)).foregroundColor(textColor) Text("\(Int(progress * 100))%").font(.system(size: 12)).foregroundColor(accentColor)
} }
} }
//NetImage(imageData: netImgData) //NetImage(imageData: netImgData)