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

Stacked in-app notification #1921

Merged
merged 9 commits into from
Apr 16, 2018
Merged

Stacked in-app notification #1921

merged 9 commits into from
Apr 16, 2018

Conversation

Odonno
Copy link
Contributor

@Odonno Odonno commented Mar 24, 2018

Issue: #1430

PR Type

What kind of change does this PR introduce?

  • Feature

What is the current behavior?

Show one notification with in-app notification control at a time.
Showing a new notification when an existing is still displayed will replace the previous one.

What is the new behavior?

Add different behavior for stacking notification:

  • Replace (same mode as before)
  • Stack above
  • Queue behind

PR Checklist

Please check if your PR fulfills the following requirements:

ContentTemplate = dataTemplate;
Content = null;
Show(duration);
bool shouldDisplayImmediately = ShouldDisplayImmediately();
Copy link
Member

Choose a reason for hiding this comment

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

Could we use Generics or another pattern here to simplify these three different types of template objects? Then the show logic could be centralized rather than triplicated, eh?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can surely create a function for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

You can change this behavior with one of these values:

* `Replace` - default mode, replace previous notification
* `QueueBehind` - store every notifications to show, when you dismiss a notification the remaining ones will be displayed successively
Copy link
Member

Choose a reason for hiding this comment

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

will be displayed in succession.

Also should this be formatted as a table?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can. But this documentation page does not follow the guidelines for the moment.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let it be like this. I will change it in #1748. Currently, I have updated the old doc. You can see it here

* `Replace` - default mode, replace previous notification
* `QueueBehind` - store every notifications to show, when you dismiss a notification the remaining ones will be displayed successively
* `StackAbove` - store every notifications to show, when you show a notification it will be displayed in priority (in the reverse order of `QueueBehind` mode)

Copy link
Member

Choose a reason for hiding this comment

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

Not sure if these names make sense for me. I thought StackAbove at first was going to show multiple notifications on screen at the same time.

Also, shouldn't the be a parameter on the show function vs. a property of the control? Shouldn't I be able to decide that I have a really important message and want it to be next, but usually I'll just queue them up in order?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well. I am not sure of the use case but the goal was to mimic the behavior of the Microsoft Edge notifications control. When you have multiple notifications, there is only one visible at a time, and displayed successfully when one is dismissed.

For your 1st question, I think this is not required, a property seems better. For your 2nd question, you can surely change the behavior as you go, from QueueBehind to StackAbove and go back to normal when you want.

Copy link
Contributor

@nmetulev nmetulev Apr 4, 2018

Choose a reason for hiding this comment

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

Agree. What about StackInFront/QueueBehind?

/// <summary>
/// Base class for information about stacked notification
/// </summary>
public abstract class StackedNotificationInfo
Copy link
Member

Choose a reason for hiding this comment

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

Maybe have this have a Generic property of ContentHolder?

Copy link
Contributor Author

@Odonno Odonno Mar 25, 2018

Choose a reason for hiding this comment

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

Well. How do you handle a type that is not part of the possible types. In F#, you could do that: string | UIElement | DataTemplate but I don't know if it is possible with generics.

Copy link
Member

Choose a reason for hiding this comment

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

public class StackedNotificationInfo<T>
{
   public int Duration { get; set; }  
   public T ContentHolder { get; set; }
}

Then you can do: public void Show<T>(T contentHolder, int duration = 0)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it better than what we have now? I mean, devs could possibly send whatever type they want. We loss the constraints of what I said earlier on restricting to string | UIElement | DataTemplate type.

Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively, you just leave it as object and do pattern matching in the UpdateContent function. If it's not one of the three types you support, either call ToString() or ignore. You have public type safety in the Show methods

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, it is possible. But what I am thinking for devs. Is it better to see a method with 3 overloads (with each recommend type) or a single method where you can insert whatever you want?

I know, this is a small argument but I prefer that we look at every angle. If you are still in favor of the generic version, I'll make the change.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should change the Show methods to take in arbitrary type, they should remain the way they are. I think the discussion here is whether we just need this:

internal class StackedNotificationInfo
{
   public int Duration { get; set; }  
   public object Content { get; set; }
}

vs what you have right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think that's what @michael-hawker wanted. But of course, I can change the shape of the internal class.

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with either, the backup behavior @nmetulev suggests makes sense too.

Copy link
Contributor

Choose a reason for hiding this comment

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

NotifcationOptions

You can change this behavior with one of these values:

| StackMode properties | Description |
| -- | -- | -- |
Copy link
Contributor

Choose a reason for hiding this comment

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

You have to remove one | -- |

/// <summary>
/// Base class for information about stacked notification
/// </summary>
public abstract class StackedNotificationInfo
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this class public?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah ah. Good eyes.

@nmetulev
Copy link
Contributor

@michael-hawker, could you review again

@michael-hawker
Copy link
Member

Looks pretty good, pinging @shweaver-MSFT though too, as I believe he was just looking at the existing in-app notification templates today.

@michael-hawker michael-hawker dismissed their stale review April 13, 2018 04:22

out of date

@shweaver-MSFT
Copy link
Member

Based on the current changes I'm seeing, I don't think this will affect the template updates I'm doing. Testing it out currently...

@azchohfi azchohfi merged commit dc2ad8f into CommunityToolkit:master Apr 16, 2018
@windowstoolkitbot
Copy link

This PR is linked to unclosed issues. Please check if one of these issues should be closed: #1430

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

Successfully merging this pull request may close these issues.

8 participants