Make appbar state poppable with the back arrow
This commit is contained in:
parent
f40a93bba8
commit
637c67a50d
@ -136,9 +136,11 @@ export function AllImagesView(vm, params, key, { appbar }) {
|
|||||||
la.subscribe(res => images.splice(0, images.length, ...res)),
|
la.subscribe(res => images.splice(0, images.length, ...res)),
|
||||||
appbar.subscribe(({ newState, oldState }) => {
|
appbar.subscribe(({ newState, oldState }) => {
|
||||||
appbarState(newState);
|
appbarState(newState);
|
||||||
|
if (!newState.selectMode && hasSelectedIDs()) {
|
||||||
|
selectedIds.clear();
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
hasSelectedIDs.subscribe(selected => {
|
hasSelectedIDs.subscribe(selected => {
|
||||||
console.log('hasSelectedIDs subscription');
|
|
||||||
if (selected && !selectMode()) {
|
if (selected && !selectMode()) {
|
||||||
pushAppBarState();
|
pushAppBarState();
|
||||||
} else if (!selected && appbarState().selectMode) {
|
} else if (!selected && appbarState().selectMode) {
|
||||||
|
|||||||
@ -17,10 +17,7 @@ export function AppBarView(vm, params, key, opts) {
|
|||||||
const title = computed(state => state.title || '', [currentState]);
|
const title = computed(state => state.title || '', [currentState]);
|
||||||
const renderButtons = computed(state => state.buttons, [currentState]);
|
const renderButtons = computed(state => state.buttons, [currentState]);
|
||||||
const hasBackButton = computed(stack => stack.length > 1, [stateStack]);
|
const hasBackButton = computed(stack => stack.length > 1, [stateStack]);
|
||||||
const stateChange = computed((c, p) => ({ newState: c, oldState: p }), [
|
const stateChange = computed(c => ({ newState: c, oldState: previousState() }), [currentState]);
|
||||||
currentState,
|
|
||||||
previousState
|
|
||||||
]);
|
|
||||||
|
|
||||||
const boxShadowStyle = computed(
|
const boxShadowStyle = computed(
|
||||||
t => (t === 0 ? 'none' : `0px ${Math.min(t / 10, 3)}px 3px rgba(0, 0, 0, .2)`),
|
t => (t === 0 ? 'none' : `0px ${Math.min(t / 10, 3)}px 3px rgba(0, 0, 0, .2)`),
|
||||||
@ -32,15 +29,13 @@ export function AppBarView(vm, params, key, opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function pushState(newState) {
|
function pushState(newState) {
|
||||||
const oldState = currentState() || {};
|
previousState(currentState());
|
||||||
stateStack.unshift(Object.assign({ _seq: seq++ }, newState));
|
stateStack.unshift(Object.assign({ _seq: seq++ }, newState));
|
||||||
previousState(oldState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function popState() {
|
function popState() {
|
||||||
const oldState = currentState();
|
previousState(currentState());
|
||||||
stateStack.shift();
|
stateStack.shift();
|
||||||
previousState(oldState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
opts.appbar = {
|
opts.appbar = {
|
||||||
@ -61,15 +56,20 @@ export function AppBarView(vm, params, key, opts) {
|
|||||||
},
|
},
|
||||||
[
|
[
|
||||||
hasBackButton()
|
hasBackButton()
|
||||||
? backButtonContainer([
|
? backButtonContainer(
|
||||||
Icon({
|
{
|
||||||
name: 'arrow_left',
|
onclick: popState
|
||||||
size: 0.75,
|
},
|
||||||
attrs: {
|
[
|
||||||
onclick: popState
|
Icon({
|
||||||
}
|
name: 'arrow_left',
|
||||||
})
|
size: 0.75,
|
||||||
])
|
attrs: {
|
||||||
|
onclick: popState
|
||||||
|
}
|
||||||
|
})
|
||||||
|
]
|
||||||
|
)
|
||||||
: null,
|
: null,
|
||||||
titleContainer(title()),
|
titleContainer(title()),
|
||||||
headerRight(_buttons())
|
headerRight(_buttons())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user