Skip to content

Reorganize data-managing widgets to accommodate global data #20

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

Merged
merged 3 commits into from
Mar 4, 2023

Conversation

gnprice
Copy link
Member

@gnprice gnprice commented Mar 3, 2023

Another step toward #13 . This sets up an appropriate home (the GlobalStore) for data like the list of accounts, and which one is the active account (the one we should immediately show on launching the app), to live.

Copy link
Collaborator

@chrisbobbe chrisbobbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Comments below.

Comment on lines 64 to 31
@override
Widget build(BuildContext context) {
if (store == null) return const LoadingPage();
return PerAccountStoreWidget(
store: store!,
child: MaterialApp(
title: 'Zulip',
theme: ThemeData(
// This applies Material 3's color system to produce a palette of
// appropriately matching and contrasting colors for use in a UI.
// The Zulip brand color is a starting point, but doesn't end up as
// one that's directly used. (After all, we didn't design it for that
// purpose; we designed a logo.) See docs:
// https://api.flutter.dev/flutter/material/ColorScheme/ColorScheme.fromSeed.html
// Or try this tool to see the whole palette:
// https://m3.material.io/theme-builder#/custom
colorScheme: ColorScheme.fromSeed(seedColor: kZulipBrandColor)),
home: const HomePage(),
));
return PerAccountStoreWidget(store: store!, child: widget.child);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

widgets/app [nfc]: Pull UI out of data-management code

After this commit, there's still one more bit of UI being directed by _PerAccountRootState: the LoadingPage() that shows when store == null. Should we pull that out too somehow? I sense that you want to use PerAccountRoot in places where a "page" won't be the right thing to build. 🙂

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, yeah. I had that thought but then forgot it. I'll leave a TODO.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines +50 to +53
// TODO add a registry of [PerAccountStore]s, like the latter's of [MessageListView]
// That will allow us to have many [PerAccountRoot] widgets for a given
// account, e.g. at the top of each page; and to access server data from
// outside any [PerAccountRoot], e.g. for handling a notification.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

many [PerAccountRoot] widgets for a given account, e.g. at the top of each page

This seems like a case where PerAccountRoot's instruction to build a "loading page" could be problematic. Until the store is available, each page will have a loading page at the top?

I don't yet understand why we'll want to have multiple PerAccountRoots per account. In what sense is each one a "root", then? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until the store is available, each page will have a loading page at the top?

Hmm, I suppose there's more for me to think through on that front. (But this is a TODO describing #21, not really part of what this PR itself does — so I think it needn't block merging this one.)

In what sense is each one a "root", then? 🤔

I think as part of this the name will change to not say "root".

I don't yet understand why we'll want to have multiple PerAccountRoots per account.

Does #21 explain it? If not, let's discuss there.

@gnprice
Copy link
Member Author

gnprice commented Mar 4, 2023

Thanks for the review! Merging, after in-person discussion on the PerAccountRoot question above.

@gnprice gnprice merged commit a6f9934 into zulip:main Mar 4, 2023
@gnprice gnprice deleted the pr-data-reorg branch March 8, 2023 00:06
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.

2 participants