-
Notifications
You must be signed in to change notification settings - Fork 72
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
Expose mainContentSlivers's enclosing context #176
Comments
The PR here: #177 |
Hi @vishna We had similar issue in our codebase and this is how we resolved it: Would something like this work in your case? |
We have an ongoing work to use WoltModalSheetPage as a widget. This will solve problems like this. ping @MbIXjkee |
Hi @ulusoyca 👋 In the example you posted, you use It might be worth changing |
@vishna This is the sneak peak PR about the changes: #149
In our use case we don't have large list, and this is why we went with this solution. However, in the example the |
I see your point :) mainContentSlivers is not a widget 🤦🏻 @TahaTesser How can we improve the API? Can you check the proposal? |
Exactly 😅 I wish there was something like: SliverBuilder((context) {
return someSliver;
}); that would solve the issue without API changes 🙄 |
@ulusoyca if we had complete test coverage we could run them to verify such cases aren't breaking anything. However, this should be relatively safe change. |
This is amazing @TahaTesser. LGTM. |
@TahaTesser why don't we introduce a breaking change? The SliverModalSheetPage is rarely used, and we are still far from 1.0, so breaking changes as the API evolves is inevitable. I think instead of keeping multiple fields, I would prefer having only mainContentSliversBuilder to avoid confusion. WDYT? |
You could also keep |
@vishna Yes, probably I should be a nice guy :) Power comes with responsibility. Thanks, a very good idea. |
If the goal is to remove it, then yes, we can make it nullable as well as mark it deprecated. This will give enough time for the user to migrate too. |
If you don't mind, I had another thought while using this package myself.
return SliverWoltModalSheetPage(
leadingNavBarWidget: IconButton(
icon: const Icon(Icons.close),
onPressed: () {
Navigator.of(context).pop(false);
}),
sabGradientColor: , // No way to edit this after build)
} Why am I doing reactively in a function, when I should be doing it in the build method of widget state.
pageListBuilder: (context) {
return [
buildProductPage(product1), // Main Product
buildProductPage(product2), // Similar Product 1
buildProductPage(product3), // Similar Product 2
buildProductPage(product4), // Similar Product 3
...
];
}, You would then need to devise some complex logic so that the main product page knows the index for each of the similar products.
final page1State = ValueNotifier(PageOneState); // Custom object to hold state
final page2State = ValueNotifier(PageTwoState); // Custom object to hold state
...
WoltModalSheet.show(
pageListBuilder: (context) {
return [
buildProductPage(product1,page1State ),
buildProductPage(product2,page2State ),
];
},
) Forgive my ramblings, I may have no idea how to use this package, but I would imagine something like this: // Sheet is a page route that can be extending with parameters
class Sheet extends Wolt...{
Sheet(this.product)
}
// Add sheet
WoltModalSheet.of(context).push(Sheet(product1))
WoltModalSheet.of(context).pop(true) |
This seems like the way to go, now it's a cross between a route (for the page) and a widget (for each component), and it feels like everything I'm doing is a workaround. (Putting local state into global state management). I may be coming off as angry or upset. Forgive me. Thank so much for this free and awesome package! |
No worries at all! We are open to feedback. We did not create this project to receive kudos. Constructive feedback helps us to be better everyday.
The problem is fundamental. We are aware of the fact that WoltModalSheetPage should be a widget. We acknowledge this was a mistake, but this was the easiest way at the time to deliver a solution according to the design specs. The rest of the components is different than mainContentSlivers because it is a list of widgets, not a single widget. For the rest, we are utilizing
In the sample app there is a demo of how to do it. The
This should be the same behavior as the bottom sheet usage in Flutter SDK. It returns data, and in fact we are returning data in our project when popped imperatively.
This is true, until the WoltModalSheet is a widget. I agree it is not nice, but for now, this works. stickyActionBar: ValueListenableBuilder(
valueListenable: actionTextEnabled,
builder: (_, isEnabled, ___) => LargeButton(
text: strings.orderHistory_modal_action,
onPressed: () {
Navigator.pop(context, selectedOptionValue);
},
disabled: !isEnabled,
),
),
Summary: All of your input is valuable and valid. At Wolt, we are in the finalization of the migration process from native iOS merchant app to Flutter merchant app that affects many users. After the migration is complete, we will have more time and freedom to focus on these changes for the package. This is why the package for now stays in 0.y.z version. |
ProblemI've began writing a controller for this package that would simplify many parts of it. _pageListBuilderNotifier.value = (BuildContext context) {
return [currentPage, page];
};
_pageIndexNotifier.value = 1; RangeError (index): Invalid value: Only valid value is 0: 1 Seems to be an issue with the sheet using the old
DiagnoseThe interesting thing is that the wolt_modal_sheet/lib/src/wolt_modal_sheet.dart Lines 220 to 226 in 7b5572a
The error is being thrown by the animation segment of the code:
It seems that I was going to post an issue but remembered you said
Am I doing this wrong, or is this a bug, (in my code most probably) ? |
I will get back to this, but you are not wrong. In my side project, I also wait for the next frame when dynamically setting the path on callback. Need to investigate why. static void _goToPage(ValueNotifier<int> pageIndexNotifier, int index) {
SchedulerBinding.instance.goToModalPageOnNextFrame(pageIndexNotifier, index);
} |
This is not the case when you set the value in the ValueNotifier for page list builder and then set the value of the valuenotifier of the page index. My theory is this: PageListeBuilder notifying requires to wait a complete rendering pipeline of a frame before setting the page list notifier. |
@dickermoshe I started working on this FYI. |
Checkout my PR, It does that. |
That's awesome! |
@dickermoshe This is my draft proposal. Needs some more cases to test with the playground. |
Merged #177 |
What feature would you like to see?
Using one of the state management libs (bloc) currently it's not possible to e.g. refresh item count of items on the list.
Given the following use of
decorator
I am not able to refresh contents of
mainContentSlivers
listAttaching a PR where I fixed the problem for myself (needs API decision from project owners tho)
The text was updated successfully, but these errors were encountered: