Skip to content

Instantly share code, notes, and snippets.

@kenmulford
Created September 30, 2025 19:50
Show Gist options
  • Select an option

  • Save kenmulford/558917f45ffe8f168bdf76e2ed0e787b to your computer and use it in GitHub Desktop.

Select an option

Save kenmulford/558917f45ffe8f168bdf76e2ed0e787b to your computer and use it in GitHub Desktop.
Rock Mobile - Profile SubNav
//- default to the authenticated person, but override with any person set via context
//- e.g. profile is loaded via search block
{%- assign Person = CurrentPerson -%}
{%- if Context.Person != null -%}
{%- assign Person = Context.Person -%}
{%- endif -%}
//- identify current page GUID
{%- assign CurrentPageGuid = 'Global' | Page:'Guid' -%}
{%- assign CurrentPageId = 'Global' | Page:'Id' -%}
{%- capture CurrentPageUrl -%}{{- CurrentPageGuid -}}?PersonGuid={{- Person.Guid -}}{%- endcapture -%}
{%- assign pageList = null -%}
{%- page where:'LayoutId == 145' -%}
{%- for p in pageItems -%}
{%- assign isActive = "false" -%}
{%- capture NavUrl -%}{{- p.Guid -}}?PersonGuid={{- Person.Guid -}}{%- endcapture -%}
{%- if p.Id == CurrentPageId -%}
{%- assign isActive = "true" -%}
{%- endif -%}
{%- assign pageId = p.Id | ToJSON -%}
{%- assign pageGuid = p.Guid -%}
{%- assign pageName = p.PageTitle -%}
{%- assign pageOrder = p.Order | ToJSON -%}
{%- assign
pageRecord = null
| AddToDictionary:'PageId', pageId
| AddToDictionary:'PageGuid', pageGuid
| AddToDictionary:'PageName', pageName
| AddToDictionary:'IsActive', isActive
| AddToDictionary:'Order', pageOrder
| AddToDictionary:'NavUrl', NavUrl
-%}
{%- assign pageList = pageList | AddToArray: pageRecord -%}
{%- endfor -%}
{%- endpage %}
{%- assign pageListSize = pageList | Size -%}
{%- assign pageJson = pageList | ToJSON -%}
<StackLayout
Padding="0"
Margin="0"
Spacing="0"
BackgroundColor="{AppThemeBinding Light=#FFFFFF, Dark=#000000}">
<Grid
Margin="0"
x:Name="npmSubNavGrid"
RowDefinitions="42"
RowSpacing="0"
ColumnSpacing="0">
<Grid.Resources>
//- Bring the JSON into memory.
<Rock:FromJson x:Key="Pages">{{ pageJson }}</Rock:FromJson>
//- Define the item template for the list.
<DataTemplate x:Key="PageItem">
<Rock:ItemViewCell>
<Grid
RowDefinitions="40,2"
ColumnDefinitions="*">
<Button
StyleClass="headline"
CornerRadius="0"
x:Name="npmSubNavItem"
Padding="8"
WidthRequest="100"
HeightRequest="40"
Margin="0"
HorizontalOptions="Center"
VerticalOptions="Center"
BackgroundColor="{AppThemeBinding Dark=#000000, Light=#FFFFFF}"
TextColor="{AppThemeBinding Light=#000000, Dark=#FFFFFF}"
Command="{Binding BindingContext.ReplacePage, Source={x:Reference Name=npmSubNavGrid}}"
CommandParameter="{Binding NavUrl}"
Text="{Binding PageName}">
<Button.Triggers>
<DataTrigger
TargetType="Button"
Binding="{Binding IsActive}"
Value="true">
<Setter
Property="IsEnabled"
Value="False" />
<Setter
Property="FontAttributes"
Value="Bold" />
</DataTrigger>
</Button.Triggers>
<VisualStateManager.VisualStateGroups>
<VisualStateGroupList>
<VisualStateGroup>
<VisualState Name="Disabled">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="{AppThemeBinding Light=#FFFFFF, Dark=#000000}" />
<Setter Property="TextColor" Value="{AppThemeBinding Light=#000000, Dark=#FFFFFF}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</VisualStateManager.VisualStateGroups>
</Button>
<BoxView
Grid.Row="1"
HeightRequest="2"
Color="{Binding IsEnabled, Source={x:Reference npmSubNavItem}, Converter={Rock:BooleanValueConverter True=#00FFFFFF, False={Rock:PaletteColor Interface-Medium}}}" />
</Grid>
</Rock:ItemViewCell>
</DataTemplate>
</Grid.Resources>
//- List the items, with the in memory items.
<Rock:ItemsCollection
ItemWidth="100"
ItemHeight="42"
CollectionLayout="Horizontal"
ItemSpacing="0"
CollectionPadding="0"
ItemsSource="{StaticResource Pages}"
ItemTemplate="{StaticResource PageItem}">
</Rock:ItemsCollection>
</Grid>
<Rock:StyledBorder
StyleClass="bg-interface-strong, border, border-1" />
</StackLayout>
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:Rock="clr-namespace:Rock.Mobile.Cms;assembly=Rock.Mobile"
xmlns:Common="clr-namespace:Rock.Mobile.Common;assembly=Rock.Mobile.Common">
<ScrollView>
<ScrollView.Effects>
<Rock:SafeAreaPaddingEffect Edges="All" />
</ScrollView.Effects>
<VerticalStackLayout>
<Rock:Zone ZoneName="SubNav" />
<Rock:Zone ZoneName="Main" Margin="10,20,10,20" />
</VerticalStackLayout>
</ScrollView>
</ContentPage>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment