Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): fix global header/footer title in ListView #14160

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented Dec 21, 2024

Issue

I don't think it is widely used but you can add a headerTitle/footerTitle in the ListView instead of the ListSection. When I was working on the test suite PR (#14158) I saw that that test was failing.

12.6.1.GA:

Screenshot_20241221-133034

The issue is that the content section has no view (as it is just the global headerTitle, so it doesn't have items) and that messes up the constraints. The "global header view" is visible as it creates a view.

Fix

As I don't know at this point which kind of headerTitle (section or global) I just check if there are views inside the content section. If not I create an empty view and add it. That will keep the constraints working

Screenshot_20241221-133112

Test

<Alloy>
	<Window id="index" layout="vertical">
		<ListView id="list" headerTitle="Global Title" footerTitle="Global footer" height="Ti.UI.SIZE"/>

		<ListView id="list" height="Ti.UI.SIZE">
			<HeaderView>
				<View height="25" backgroundColor="teal">
					<Label>Global Header View</Label>
				</View>
			</HeaderView>
		</ListView>

		<ListView id="list">
			<ListSection>
				<HeaderView>
					<View height="25" backgroundColor="teal">
						<Label>Section Only Header View</Label>
					</View>
				</HeaderView>
			</ListSection>

			<ListSection headerTitle="Only header title">
				<ListItem title="Item 1" backgroundColor='pink'/>
			</ListSection>

			<!-- <ListSection footerTitle="Only footer title" backgroundColor='green'/> -->

			<ListSection>
				<ListItem title="Section item 1 : no header/footer"/>
				<ListItem title="Section item 2 : no header/footer"/>
			</ListSection>

			<ListSection>
				<HeaderView>
					<View height="50" backgroundColor="pink">
						<Label>Section with :: Header Footer View</Label>
					</View>
				</HeaderView>

				<FooterView>
					<View height="25" backgroundColor="green">
						<Label>Section with Header :: Footer View</Label>
					</View>
				</FooterView>
			</ListSection>

			<ListSection>
				<HeaderView>
					<View height="50" backgroundColor="magenta">
						<Label>Section 2 : Header View</Label>
					</View>
				</HeaderView>

				<ListItem title="Section footer/header : Item 1"/>
				<ListItem title="Section footer/header : Item 2"/>

				<FooterView>
					<View height="25" backgroundColor="orange">
						<Label>Section 2 : Footer View</Label>
					</View>
				</FooterView>
			</ListSection>

			<ListSection>
				<ListItem title="Section 3 : Item 0"/>
				<ListItem title="Section 3 : Item 1"/>
				<ListItem title="Section 3 : Item 2"/>
				<ListItem title="Section 3 : Item 3"/>
				<ListItem title="Section 3 : Item 4"/>
				<ListItem title="Section 3 : Item 5"/>
				<ListItem title="Section 3 : Item 6"/>
				<ListItem title="Section 3 : Item 7"/>
				<ListItem title="Section 3 : Item 8"/>
				<ListItem title="Section 3 : Item 9"/>
				<ListItem title="Section 3 : Item 10"/>
				<ListItem title="Section 3 : Item 11"/>
				<ListItem title="Section 3 : Item 12"/>
				<FooterView>
					<View height="25" backgroundColor="red">
						<Label>Section 3 : Footer View</Label>
					</View>
				</FooterView>
			</ListSection>
		</ListView>
	</Window>
</Alloy>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant