The details view is shown when the user scans a code or clicks on an item in the recent scans list. It shows the content of the scan and the date, as shown in the following screenshot:
If the content of the scan is a URL, we will show a button to open that link, as shown in the following screenshot:
At the end of this chapter, we will style this page properly.
We add a function to src/model.ts
that will return true
when the scan (probably) contains a URL. We consider a scan that contains no spaces and begins with http://
or https://
to be a URL:
function startsWith(input: string, start: string) { return input.substring(0, start.length) === start; } export function isUrl({ content }: Scan) { if (content.indexOf(" ") !== -1) { return false; } return startsWith(content, "http://") || startsWith(content, "https://"); }
The view requires the scan itself and optionally a callback. The callback will only...