The error: The compiler is unable to type-check the expression in real-time
generally means you're trying to do too many things in one place, and you should break it down a little.
Firstly, to make it more readable, I'd put brackets around each ternary expression, for example: (row %2 == 0 ? Color.blue : Color.orange)
so you can see which bits are enclosed.
Then I'd split it out like this, creating a let
for the various bits so they're individually evaluated prior to the larger expression. Also, I'd indent the code so it's more readable, putting the positive on the first line, and the negative on the next line, indented:
let borderColor1 = (row %2 == 0 ? Color.blue : Color.orange)
let borderColor2 = (shelterViewModel.getShelter(row: row, column: column).productId = ViewConstants.LAYOUT_DUMMY_ID ? Color.yellow : Color.green)
.border(
(shelterViewModel.getShelter0perationFormat() ? borderColor1
: (locationViewModel.getLocation(row: row, column: column) ? Color.red
: borderColor2)),
width: 0.5 //(self.interfaceLayout == ViewConstants.BACKEND_OPERATION ? 0.5 : 0.5)
)
Finally, this bit at the end is pointless as the two values are the same: width: (self.interfaceLayout == ViewConstants.BACKEND_OPERATION ? 0.5 : 0.5)
so you can replace it with 0.5
, unless you're going to change one of those values?