Skip to content

Commit 408ccd4

Browse files
responsive fixes
1 parent f852610 commit 408ccd4

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

samples/FluidHostPage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public FluidHostPage()
2929
if (bp == ActiveBreakpoint) return;
3030

3131
ActiveBreakpoint = bp;
32-
BreakpointChanged?.Invoke(ActiveBreakpoint);
32+
BreakpointChanged?.Invoke();
3333
};
3434

3535
Presenter = _presenter;
@@ -38,7 +38,7 @@ public FluidHostPage()
3838
public View Presenter { get; }
3939
public BreakPoint ActiveBreakpoint { get; private set; } = BreakPoint.sm;
4040

41-
public event Action<BreakPoint>? BreakpointChanged;
41+
public event Action? BreakpointChanged;
4242

4343
public void ShowView(View view)
4444
{

src/FluidView.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ public abstract class FluidView : ResponsiveView
55
public FluidView()
66
{
77
Content = GetView();
8+
OnBreakpointChanged();
89
}
910

1011
public TransitionView? TransitionView { get; private set; }

src/IFluidHost.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public interface IFluidHost
2828
/// <summary>
2929
/// Called when the breakpoint changes.
3030
/// </summary>
31-
event Action<BreakPoint> BreakpointChanged;
31+
event Action BreakpointChanged;
3232

3333
/// <summary>
3434
/// Shows the specified view.

src/ResponsiveView.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ public ResponsiveView()
1010

1111
public BreakPoint ActiveBreakpoint => FlowNavigation.Current.View.ActiveBreakpoint;
1212

13-
protected virtual void OnBreakpointChanged(BreakPoint breakPoint)
13+
protected virtual void OnBreakpointChanged()
1414
{
15-
var bp = (int)breakPoint;
15+
var bp = (int)FlowNavigation.Current.View.ActiveBreakpoint;
1616

1717
OnSm();
1818
if (bp >= 1) OnMd();

src/TransitionView.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ public bool RemoveState<TView>()
2727
public TransitionView Complete(Type type, IEnumerable<Flow>? flow = null)
2828
{
2929
_activeType = type;
30-
return FluidAnimationsExtensions.Complete(this, flow ?? GetBreakpointFlow(type, ActiveBreakpoint));
30+
return FluidAnimationsExtensions.Complete(this, flow ?? GetBreakpointFlow(type));
3131
}
3232

3333
public Task<bool> Animate(Type type, IEnumerable<Flow>? flow = null)
3434
{
3535
_activeType = type;
36-
return FluidAnimationsExtensions.Animate(this, flow ?? GetBreakpointFlow(type, ActiveBreakpoint));
36+
return FluidAnimationsExtensions.Animate(this, flow ?? GetBreakpointFlow(type));
3737
}
3838

3939
/// <summary>
@@ -71,13 +71,15 @@ public static DataTemplate Build<TFromView, TToView, TTransitionView>(
7171
})
7272
.Complete(typeof(TFromView));
7373

74+
transitionView.OnBreakpointChanged();
75+
7476
return transitionView;
7577
});
7678
}
7779

78-
protected override void OnBreakpointChanged(BreakPoint breakPoint)
80+
protected override void OnBreakpointChanged()
7981
{
80-
base.OnBreakpointChanged(breakPoint);
82+
base.OnBreakpointChanged();
8183

8284
_ = Complete(_activeType);
8385
}
@@ -93,15 +95,16 @@ private void SetBreakpointFlow(Type type, BreakPoint breakpoint, IEnumerable<Flo
9395
typeFlows[(int)breakpoint] = flow;
9496
}
9597

96-
private IEnumerable<Flow> GetBreakpointFlow(Type type, BreakPoint breakpoint)
98+
private IEnumerable<Flow> GetBreakpointFlow(Type type)
9799
{
98100
var flowsOnType = _flows[type];
99-
var i = (int)breakpoint;
101+
var i = (int)FlowNavigation.Current.View.ActiveBreakpoint;
100102
var flow = flowsOnType[i];
101103

102104
while (flow is null && i > 0)
103105
flow = flowsOnType[--i];
104106

105-
return flow ?? throw new Exception($"No flow found for {type.Name} at breakpoint {breakpoint}");
107+
return flow ??
108+
throw new Exception($"No flow found for {type.Name} at breakpoint {FlowNavigation.Current.View.ActiveBreakpoint}");
106109
}
107110
}

0 commit comments

Comments
 (0)