Salah 0.3: larger AMOLED UI with swipe-scrollable prayers
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
const assert = require('node:assert/strict')
|
||||
const fs = require('node:fs')
|
||||
const src = fs.readFileSync('src/pages/index/index.ux', 'utf8')
|
||||
const manifest = JSON.parse(fs.readFileSync('src/manifest.json'))
|
||||
function css(name, prop) {
|
||||
const block = src.match(new RegExp('\\.' + name + '\\s*\\{([^}]+)'))[1]
|
||||
return block.match(new RegExp(prop + ':\\s*([^;]+)'))[1].trim()
|
||||
}
|
||||
assert.equal(css('page', 'background-color'), '#000000', 'page must be AMOLED black')
|
||||
assert.equal(manifest.display.backgroundColor, '#000000')
|
||||
assert.match(src, /<list\s[^>]*class="prayers"/, 'native swipe-scrollable list')
|
||||
assert.match(src, /<list-item[^>]*type="prayer"[^>]*for="\{\{ row in rows \}\}"/)
|
||||
assert.ok(parseFloat(css('rowName', 'font-size')) >= 28)
|
||||
assert.ok(parseFloat(css('rowTime', 'font-size')) >= 36)
|
||||
const top = parseFloat(css('prayers', 'top'))
|
||||
const height = parseFloat(css('prayers', 'height'))
|
||||
const width = parseFloat(css('prayers', 'width'))
|
||||
const dy = Math.max(Math.abs(top - 233), Math.abs(top + height - 233))
|
||||
assert.ok(width <= 2 * Math.sqrt(233 ** 2 - dy ** 2) - 20, 'whole scroll viewport fits circle')
|
||||
const rowH = parseFloat(css('row', 'height'))
|
||||
const pad = parseFloat(css('spacer', 'height'))
|
||||
assert.equal(pad, (height - rowH) / 2, 'first/last rows can reach viewport center')
|
||||
assert.ok(6 * rowH + 2 * pad > height, 'content actually scrolls')
|
||||
assert.ok(!src.includes('onBackPress'), 'system back still exits')
|
||||
console.log('AMOLED, large text, scroll wiring and circular viewport checks passed')
|
||||
+4
-12
@@ -148,18 +148,10 @@ test('update() rows: six entries, key+label+time wired', () => {
|
||||
}
|
||||
})
|
||||
|
||||
test('row widths taper with the chord and fit the 466 circle at every row position', () => {
|
||||
// rows: 6 x 40px + 5 x 4px margins, block starts after header+banner (top=130)
|
||||
const ROW_WIDTHS = spec.ROW_WIDTHS || sandbox.ROW_WIDTHS
|
||||
assert.equal(ROW_WIDTHS.length, 6)
|
||||
const H = 40, MARGIN = 4, BLOCK_TOP = 130, R = 233, INSET = 10
|
||||
for (let n = 0; n < 6; n++) {
|
||||
const top = BLOCK_TOP + n * (H + MARGIN)
|
||||
const dy = Math.max(Math.abs(233 - top), Math.abs(233 - (top + H)))
|
||||
const chord = 2 * Math.sqrt(Math.max(0, R * R - dy * dy))
|
||||
const safe = chord - 2 * INSET
|
||||
assert.ok(ROW_WIDTHS[n] <= safe, `row ${n} width ${ROW_WIDTHS[n]} exceeds safe chord ${safe.toFixed(0)} at top ${top}`)
|
||||
}
|
||||
test('all rows fit the scroll viewport', () => {
|
||||
const widths = sandbox.ROW_WIDTHS
|
||||
assert.equal(widths.length, 6)
|
||||
widths.forEach(width => assert.equal(width, 320))
|
||||
})
|
||||
|
||||
test('bound rowStyle width equals ROW_WIDTHS[i]', () => {
|
||||
|
||||
Reference in New Issue
Block a user