feat: add download data empty state button to keyboard (#627)#629
feat: add download data empty state button to keyboard (#627)#629prince-0408 wants to merge 2 commits intoscribe-org:mainfrom
Conversation
Thank you for the pull request! 💙The Scribe-iOS team will do our best to address your contribution as soon as we can. If you're not already a member of our public Matrix community, please consider joining! We'd suggest that you use the Element client as well as Element X for a mobile app, and definitely join the Note Scribe uses Conventional Comments in reviews to make sure that communication is as clear as possible. |
Maintainer ChecklistThe following is a checklist for maintainers to make sure this process goes as well as possible. Feel free to address the points below yourself in further commits if you realize that actions are needed :) |
|
Thanks for this, @prince-0408! Sorry to ask you to do a bunch of reformatting, but then it'll only be done this once :) Can you switch this over to four spaces to match the new style? |
When a Scribe keyboard is installed but language data has not been
downloaded yet, a blue 'Please download language data' button now
appears at the top of the keyboard. Tapping it opens the Scribe app
and navigates directly to the Download Data screen.
Changes:
- KeyboardViewController.swift
- Added downloadDataBtn (UIButton?) property
- Added hasLanguageData() to check if the language SQLite file
exists in the shared app group container
- Added showDownloadDataBtn() to create and layout the blue CTA
button at the top of the keyboard view
- Added conditionallyShowDownloadDataBtn() to show/hide the button
based on data availability and current command state (only shown
in .idle state, hidden during translate/conjugate/plural/info)
- Added openScribeApp() using the UIResponder chain to open the
scribe:// URL scheme and direct the user to the download screen
- Called conditionallyShowDownloadDataBtn() at the end of loadKeys()
- Button is also hidden during displayInformation state
- CommandVariables.swift
- Added downloadDataMsg variable with default English fallback text
'Please download language data'
- Language interface variables (all 11 keyboards)
- ENInterfaceVariables: 'Please download language data'
- DEInterfaceVariables: 'Bitte Sprachdaten herunterladen'
- FRInterfaceVariables: 'Veuillez télécharger les données linguistiques'
- ESInterfaceVariables: 'Por favor descarga los datos del idioma'
- ITInterfaceVariables: 'Scarica i dati della lingua'
- PTInterfaceVariables: 'Por favor baixe os dados do idioma'
- RUInterfaceVariables: 'Загрузите языковые данные'
- SVInterfaceVariables: 'Ladda ner språkdata'
- NBInterfaceVariables: 'Last ned språkdata'
- HEInterfaceVariables: 'אנא הורד נתוני שפה'
- IDInterfaceVariables: 'Unduh data bahasa'
- Scribe/Info.plist
- Registered scribe:// URL scheme (CFBundleURLSchemes) so the app
can be opened from the keyboard extension
- Scribe/AppDelegate.swift
- Added application(_:open:options:) handler for the scribe:// URL
- Posts NavigateToDownloadScreen notification which InstallationVC
already handles to push the DownloadDataScreen
Closes scribe-org#627
a5d3c37 to
319c81e
Compare
|
Done! @andrewtavis |
Description
Closes #627
This PR implements the empty state for Scribe keyboards when the keyboard
has been installed but language data has not yet been downloaded. A blue
"Please download language data" button now appears at the top of the
keyboard, matching the Figma design. Tapping the button opens the Scribe
app and navigates directly to the Download Data screen.
Changes Made
Keyboards/KeyboardsBase/KeyboardViewController.swiftdownloadDataBtn(UIButton?) property to hold a reference tothe empty state button
hasLanguageData()— checks if the language SQLite file existsin the shared app group container (
group.be.scri.userDefaultsContainer)showDownloadDataBtn()— creates and lays out the blue CTA buttonpinned to the top of the keyboard view using Auto Layout
conditionallyShowDownloadDataBtn()— shows or hides the buttonbased on data availability; only shown in
.idlecommand state, hiddenduring translate / conjugate / plural / displayInformation states
openScribeApp()— uses theUIResponderchain to open thescribe://URL scheme, directing the user to the Scribe app download screenconditionallyShowDownloadDataBtn()at the end ofloadKeys()so it re-evaluates on every keyboard load
Keyboards/KeyboardsBase/ScribeFunctionality/CommandVariables.swiftdownloadDataMsgvariable with default English fallback:"Please download language data"Language Interface Variables (11 keyboards)
Added localized
downloadDataMsgto each keyboard's layout function:Scribe/Info.plistscribe://custom URL scheme (CFBundleURLSchemes) sothe Scribe app can be opened from the keyboard extension
Scribe/AppDelegate.swiftapplication(_:open:options:)handler for thescribe://URL schemeNavigateToDownloadScreennotification whichInstallationVCalready listens for and handles by pushingDownloadDataScreenTesting
appears at top of keyboard
button is gone
is hidden during command mode
correctly
Notes
UIResponderchain URL trick works on a real device. In thesimulator the button visibility can be tested but the tap-to-open
behaviour requires a physical device
RequestsOpenAccessremainsfalsein the keyboard extension —the responder chain approach does not require full access