Practice Manual and Settings were treated as fullscreen pages, so the desktop rail disappeared and the whole page shifted 88px on each tab switch. They now keep the rail and the Practice highlight; the bottom dock still hides on those tabs.
179 lines
5.1 KiB
C
179 lines
5.1 KiB
C
#include "app/app_nav_state.h"
|
|
#include "zir_string.h"
|
|
|
|
#include <assert.h>
|
|
#include <string.h>
|
|
|
|
static int account_present;
|
|
static const char *account_alias;
|
|
static const char *public_key;
|
|
static int public_key_reads;
|
|
static const char public_id[] =
|
|
"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
|
|
|
|
int32_t sync_account_load(AccountKeys *account)
|
|
{
|
|
(void)account;
|
|
assert(0 && "Navigation must not load private account keys");
|
|
return 0;
|
|
}
|
|
|
|
String storage_get_setting_text(String key)
|
|
{
|
|
if (StringEqual(key, StringView("sync_public_id", 14)))
|
|
return StringView(public_id, account_present ? sizeof(public_id) - 1 : 0);
|
|
if (StringEqual(key, StringView("sync_public_key", 15))) {
|
|
public_key_reads++;
|
|
return StringView(public_key, strlen(public_key));
|
|
}
|
|
assert(StringEqual(key, StringView("sync_account_alias", 18)));
|
|
return StringView(account_alias, strlen(account_alias));
|
|
}
|
|
|
|
String LocaleText(String key)
|
|
{
|
|
assert(StringEqual(key, StringView("tab_profile", 11)));
|
|
return StringView("Profile", 7);
|
|
}
|
|
|
|
bool AppMiniMode(void)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool node_apps_NodeAppImmersive(int32_t slot)
|
|
{
|
|
(void)slot;
|
|
return false;
|
|
}
|
|
|
|
String node_apps_NodeAppName(int32_t slot)
|
|
{
|
|
(void)slot;
|
|
return StringView("", 0);
|
|
}
|
|
|
|
String app_records_NodeAppReplacement(String name)
|
|
{
|
|
(void)name;
|
|
return StringView("", 0);
|
|
}
|
|
|
|
int32_t route_types_AppNavNodeSlot(int32_t route)
|
|
{
|
|
(void)route;
|
|
return -1;
|
|
}
|
|
|
|
int32_t route_types_AppNavNodeRoute(int32_t slot)
|
|
{
|
|
(void)slot;
|
|
return 0;
|
|
}
|
|
|
|
int32_t AppsInstalledMask(void)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
int32_t DesktopPlatform(void)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
bool IsDesktopWidth(int32_t view_width, float scale)
|
|
{
|
|
(void)view_width;
|
|
(void)scale;
|
|
return true;
|
|
}
|
|
|
|
int32_t AppScale(int32_t pixels)
|
|
{
|
|
return pixels;
|
|
}
|
|
|
|
/* A Practice tab switch keeps the left rail and Practice highlighted, so the
|
|
* page beside it never moves sideways. */
|
|
static void check_practice_tabs_keep_rail(void)
|
|
{
|
|
static InnerBreeze app;
|
|
const int32_t tabs[] = {PRACTICE_TAB_PLAY, PRACTICE_TAB_MANUAL,
|
|
PRACTICE_TAB_CONFIG, PRACTICE_TAB_PLAY};
|
|
memset(&app, 0, sizeof(app));
|
|
app.navigation_placement = NavigationPlacement_NAVIGATION_LEFT;
|
|
app.ui.navigation_height = 720;
|
|
app.ui.view_width = 900;
|
|
app.breathing.screen = ScreenStart;
|
|
app.main_tab = AppMainTab_APP_MAIN_TAB_PRACTICE;
|
|
for (size_t i = 0; i < sizeof(tabs) / sizeof(tabs[0]); i++) {
|
|
app.practice_tab = tabs[i];
|
|
assert(app_nav_desktop_rail_enabled(&app) == 1);
|
|
assert(app_navigation_height(&app) == 0);
|
|
assert(app_current_nav_route(&app) == AppNavRoute_APP_NAV_ROUTE_PRACTICE);
|
|
}
|
|
}
|
|
|
|
String AppTextFromCString(uint8_t *data, int32_t capacity)
|
|
{
|
|
int32_t length = 0;
|
|
while (length < capacity && data[length] != 0)
|
|
length++;
|
|
return StringView((const char *)data, (size_t)length);
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
InnerBreeze app;
|
|
uint8_t name[64];
|
|
uint8_t subtitle[64];
|
|
uint8_t small[5];
|
|
Slice out = {name, sizeof(name)};
|
|
Slice sub = {subtitle, sizeof(subtitle)};
|
|
memset(&app, 0, sizeof(app));
|
|
|
|
check_practice_tabs_keep_rail();
|
|
app_reset_bottom_nav_routes(&app);
|
|
assert(app.bottom_nav_route_count == 4);
|
|
assert(app.bottom_nav_routes[0] == AppNavRoute_APP_NAV_ROUTE_LUMI);
|
|
assert(app.bottom_nav_routes[1] == AppNavRoute_APP_NAV_ROUTE_HABITS);
|
|
assert(app.bottom_nav_routes[2] == AppNavRoute_APP_NAV_ROUTE_PRACTICE);
|
|
assert(app.bottom_nav_routes[3] == AppNavRoute_APP_NAV_ROUTE_SETTINGS);
|
|
account_present = 0;
|
|
account_alias = "";
|
|
public_key = "fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876549876";
|
|
app_nav_profile_identity(&app, out, sizeof(name), sub, sizeof(subtitle));
|
|
assert(strcmp((char *)name, "Profile") == 0);
|
|
assert(subtitle[0] == 0);
|
|
|
|
account_present = 1;
|
|
account_alias = "nara";
|
|
app_nav_profile_identity(&app, out, sizeof(name), sub, sizeof(subtitle));
|
|
assert(strcmp((char *)name, "nara") == 0);
|
|
assert(strcmp((char *)subtitle, "@nara") == 0);
|
|
|
|
memcpy(app.profile_display_name, "Breeze", 7);
|
|
app_nav_profile_identity(&app, out, sizeof(name), sub, sizeof(subtitle));
|
|
assert(strcmp((char *)name, "nara") == 0);
|
|
assert(strcmp((char *)subtitle, "@nara") == 0);
|
|
assert(public_key_reads == 0);
|
|
|
|
account_alias = "";
|
|
app_nav_profile_identity(&app, out, sizeof(name), sub, sizeof(subtitle));
|
|
assert(strcmp((char *)name, "fedc...9876") == 0);
|
|
assert(strcmp((char *)subtitle, "Profile") == 0);
|
|
|
|
app_nav_profile_identity(&app, (Slice){small, sizeof(small)}, 5,
|
|
sub, sizeof(subtitle));
|
|
assert(strcmp((char *)small, "fedc") == 0);
|
|
|
|
/* Delegated/older profiles may retain only the public account ID. */
|
|
public_key = "";
|
|
app_nav_profile_identity(&app, out, sizeof(name), sub, sizeof(subtitle));
|
|
assert(strcmp((char *)name, "0123...cdef") == 0);
|
|
account_present = 0;
|
|
app_nav_profile_identity(&app, out, sizeof(name), sub, sizeof(subtitle));
|
|
assert(strcmp((char *)name, "Profile") == 0);
|
|
return 0;
|
|
}
|