Skip to content

Commit

Permalink
Merge pull request #28 from bartreardon/fix_fullscreen
Browse files Browse the repository at this point in the history
Fix fullscreen and some other cleanup
  • Loading branch information
bartreardon committed Jul 18, 2021
2 parents 382a425 + fac7908 commit b765d33
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 127 deletions.
19 changes: 12 additions & 7 deletions dialog/UI/ButtonView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,30 @@ struct ButtonView: View {
if CLOptionPresent(OptionName: CLOptions.button2Option){
Button(action: {quitDialog(exitCode: 2)}, label: {
Text(appvars.button2Default)
.frame(minWidth: 40, alignment: .center)
}
).frame(minWidth: 36, alignment: .center)
)
.keyboardShortcut(.cancelAction)
} else if CLOptionPresent(OptionName: CLOptions.button2TextOption) {
let button2Text: String = CLOptionText(OptionName: CLOptions.button2TextOption, DefaultValue: appvars.button2Default)
Button(action: {quitDialog(exitCode: 2)}, label: {
Text(button2Text)
.frame(minWidth: 40, alignment: .center)
}
).frame(minWidth: 36, alignment: .center)
)
.keyboardShortcut(.cancelAction)
}
}
// default button aka button 1
let button1Text: String = CLOptionText(OptionName: CLOptions.button1TextOption, DefaultValue: appvars.button1Default)
HStack {
//HStack {
Button(action: {buttonAction(action: self.button1action, exitCode: 0, executeShell: self.buttonShellAction)}, label: {
Text(button1Text)
.frame(minWidth: 40, alignment: .center)
}
).frame(minWidth: 36, alignment: .center)
)//.frame(minWidth: 36, alignment: .center)
.keyboardShortcut(.defaultAction)
}
//}
}
}

Expand All @@ -61,14 +64,16 @@ struct MoreInfoButton: View {
if CLOptionPresent(OptionName: CLOptions.infoButtonOption) {
Button(action: {buttonAction(action: buttonInfoAction, exitCode: 3, executeShell: false)}, label: {
Text(appvars.buttonInfoDefault)
.frame(minWidth: 40, alignment: .center)
}
).frame(minWidth: 36, alignment: .center)
)
} else if CLOptionPresent(OptionName: CLOptions.buttonInfoTextOption) {
let buttonInfoText: String = CLOptionText(OptionName: CLOptions.buttonInfoTextOption, DefaultValue: appvars.buttonInfoDefault)
Button(action: {buttonAction(action: buttonInfoAction, exitCode: 3, executeShell: false)}, label: {
Text(buttonInfoText)
.frame(minWidth: 40, alignment: .center)
}
).frame(minWidth: 36, alignment: .center)
)
}
Spacer()
}
Expand Down
70 changes: 36 additions & 34 deletions dialog/UI/FullscreenView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,13 @@ struct FullscreenView: View {
//maxBannerHeight = 150
}

//debugColour = Color.red
debugColour = Color.red

if appvars.titleFontColour == Color.primary {
appvars.titleFontColour = Color.white

}

}

public func showFullScreen() {
Expand All @@ -98,54 +103,50 @@ struct FullscreenView: View {

VStack{
// banner image vstack
VStack{
if CLOptionPresent(OptionName: CLOptions.bannerImage) {
Image(nsImage: getImageFromPath(fileImagePath: BannerImageOption))
.resizable()
.clipShape(RoundedRectangle(cornerRadius: 15))
.scaledToFit()
.frame(maxWidth: maxBannerWidth, maxHeight: maxBannerHeight)
// Horozontal Line
VStack{
Rectangle()
.fill(Color.gray.opacity(0.5))
.frame(height: 2)
}
.frame(width: (maxBannerWidth))
.padding(.vertical,20)
.border(debugColour)
if CLOptionPresent(OptionName: CLOptions.bannerImage) {
Image(nsImage: getImageFromPath(fileImagePath: BannerImageOption))
.resizable()
.clipShape(RoundedRectangle(cornerRadius: 15))
.scaledToFit()
.frame(maxWidth: maxBannerWidth, maxHeight: maxBannerHeight)
// Horozontal Line
VStack{
Rectangle()
.fill(Color.gray.opacity(0.5))
.frame(height: 2)
}
}.padding(bannerPadding) //padding for the top of the display
.border(debugColour)
.frame(width: (maxBannerWidth))
.padding(.vertical,20)
//.border(debugColour)
}

// title vstack
VStack{
HStack {
Spacer()
Text(TitleViewOption)
.foregroundColor(.white)
.bold()
.font(.system(size: titleContentFontSize))
Spacer()
}
.border(debugColour)
HStack {
// the spacers in this section push the title and thus the full screen area across the width of the display
Spacer()
Text(TitleViewOption)
.foregroundColor(appvars.titleFontColour)
.bold()
.font(.system(size: titleContentFontSize, weight: appvars.titleFontWeight))
.multilineTextAlignment(.center)
Spacer()
}
//.border(Color.blue)
//.border(Color.green)

// icon and message vstack group
VStack {
// icon vstack
VStack {
if CLOptionPresent(OptionName: CLOptions.iconOption) {
IconView()
.frame(maxHeight: appvars.imageHeight*iconImageScaleFactor, alignment: .center)
//.frame(maxHeight: appvars.imageHeight*iconImageScaleFactor, alignment: .center)
//.background(Color.white)
} else {
VStack{}.padding(emptyStackPadding)
}
}
.padding(40)
.border(debugColour)
//.border(Color.orange)

// message vstack
VStack() {
Expand All @@ -156,13 +157,14 @@ struct FullscreenView: View {
.lineLimit(12)
.lineSpacing(messageTextLineSpacing)

}.border(debugColour)
}
//.border(debugColour)
.padding(10)
.frame(maxHeight: .infinity, alignment: .center) // setting to .infinity should make the message content take up the remainder of the screen
}
.padding(.horizontal, 20) // total padding for the icon/message group
.padding(.vertical, 50)
.border(debugColour)
//.border(debugColour)
}
//.background(Color.black)
.background(
Expand Down
69 changes: 29 additions & 40 deletions dialog/UI/IconOverlayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import Foundation
import SwiftUI

struct IconOverlayView: View {
let overlayWidth: CGFloat = appvars.imageWidth * appvars.overlayIconScale
let overlayHeight: CGFloat = appvars.imageHeight * appvars.overlayIconScale

let overlayImagePath: String = CLOptionText(OptionName: CLOptions.overlayIconOption)
var imgFromURL: Bool = false
Expand All @@ -33,9 +31,8 @@ struct IconOverlayView: View {

var sfGradientPresent: Bool = false

init(overlayWidth: CGFloat? = nil, overlayHeight: CGFloat? = nil) {
//self.overlayWidth = appvars.imageWidth * appvars.overlayIconScale
//self.overlayHeight = appvars.imageHeight * appvars.overlayIconScale
init() {

if overlayImagePath.starts(with: "http") {
imgFromURL = true
}
Expand All @@ -44,7 +41,6 @@ struct IconOverlayView: View {
}

if overlayImagePath.hasPrefix("SF=") {
//print("sf present")
sfSymbolPresent = true
builtInIconPresent = true

Expand All @@ -54,15 +50,17 @@ struct IconOverlayView: View {
for value in SFValues {
// split by =
let item = value.components(separatedBy: "=")
let itemName = item[0]
let itemValue = item[1]

if item[0] == "SF" {
builtInIconName = item[1]
if itemName == "SF" {
builtInIconName = itemValue
}
if item[0] == "weight" {
if itemName == "weight" {
builtInIconWeight = textToFontWeight(item[1])
}
if item[0].hasPrefix("colour") || item[0].hasPrefix("color") {
if item[1] == "auto" {
if itemName.hasPrefix("colour") || itemName.hasPrefix("color") {
if itemValue == "auto" {
// detecting sf symbol properties seems to be annoying, at least in swiftui 2
// this is a bit of a workaround in that we let the user determine if they want the multicolour SF symbol
// or a standard template style. sefault is template. "auto" will use the built in SF Symbol colours
Expand All @@ -71,15 +69,12 @@ struct IconOverlayView: View {

iconRenderingMode = Image.TemplateRenderingMode.template // switches to monochrome which allows us to tint the sf symbol

if item[0].hasSuffix("2") {
if itemName.hasSuffix("2") {
sfGradientPresent = true
builtInIconSecondaryColour = stringToColour(item[1])
builtInIconSecondaryColour = stringToColour(itemValue)
} else {
builtInIconColour = stringToColour(item[1])
builtInIconColour = stringToColour(itemValue)
}
//} else {
//quitDialog(exitCode: 14, exitMessage: "Hex value for colour is not valid: \(item[1])")
//print("Hex value for colour is not valid: \(item[1])")
}
} else {
iconRenderingMode = Image.TemplateRenderingMode.template
Expand All @@ -95,8 +90,8 @@ struct IconOverlayView: View {
}
if overlayImagePath == "caution" {
builtInIconName = "exclamationmark.triangle.fill"
builtInIconFill = "triangle.fill"
builtInIconColour = Color.yellow
//builtInIconFill = "triangle.fill"
//builtInIconColour = Color.yellow
builtInIconPresent = true
}
if overlayImagePath == "info" {
Expand All @@ -110,18 +105,18 @@ struct IconOverlayView: View {
ZStack {
if builtInIconPresent {
ZStack {
//background square so the SF Symbol "pops"
Image(systemName: "square.fill")
.resizable()
.foregroundColor(.background)
.frame(width: overlayWidth, height: overlayWidth)
.font(Font.title.weight(Font.Weight.thin))
.opacity(0.90)

if sfSymbolPresent {
//background square so the SF Symbol has something to render against
Image(systemName: "square.fill")
.resizable()
.foregroundColor(.background)
.font(Font.title.weight(Font.Weight.thin))
.opacity(0.90)
.shadow(color: .secondaryBackground.opacity(0.50), radius: 4, x:2, y:2) // gives the sf background some pop especially in dark mode
}
ZStack() {
if sfGradientPresent {
LinearGradient(gradient: Gradient(colors: [builtInIconColour, builtInIconSecondaryColour]), startPoint: .top, endPoint: .bottomTrailing)
//LinearGradient(gradient: Gradient(colors: [.clear, .clear]), startPoint: .top, endPoint: .bottom)
.mask(
Image(systemName: builtInIconName)
.renderingMode(iconRenderingMode)
Expand All @@ -133,16 +128,14 @@ struct IconOverlayView: View {
} else {
// background colour
ZStack {

// first image required to render as background fill (hopefully this is fixed in later versions of sf symbols, e.g. caution symbol
Image(systemName: builtInIconFill)
.resizable()
.aspectRatio(contentMode: .fit)
.scaledToFit()
.foregroundColor(Color.white)
.font(Font.title.weight(builtInIconWeight))
//}
//forground image
//ZStack {

Image(systemName: builtInIconName)
.renderingMode(iconRenderingMode)
.resizable()
Expand All @@ -153,28 +146,24 @@ struct IconOverlayView: View {
}
}
}
.frame(width: overlayWidth*0.8, height: overlayWidth*0.8)
//.shadow(color: stringToColour("#FFEEFF"), radius: 6, x: 1, y: 1)
.scaleEffect(0.8)
}
.aspectRatio(1, contentMode: .fit)
} else if imgFromAPP {
Image(nsImage: getAppIcon(appPath: overlayImagePath, withSize: overlayWidth))
Image(nsImage: getAppIcon(appPath: overlayImagePath))
.resizable()
.aspectRatio(contentMode: .fit)
.scaledToFit()
} else { //if FileManager.default.fileExists(atPath: overlayImagePath) {
} else {
let diskImage: NSImage = getImageFromPath(fileImagePath: overlayImagePath, imgWidth: appvars.imageWidth, imgHeight: appvars.imageHeight, returnErrorImage: false)
Image(nsImage: diskImage)
.resizable()
.aspectRatio(contentMode: .fit)
.scaledToFit()
.clipShape(RoundedRectangle(cornerRadius: 5))
}

}
.frame(width: overlayWidth, height: overlayHeight)
.offset(x: appvars.overlayOffsetX, y: appvars.overlayOffsetY)
.shadow(color: Color.primary.opacity(0.70), radius: appvars.overlayShadow)
//.border(Color.red)
}
}
}
Expand Down

0 comments on commit b765d33

Please sign in to comment.