mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
chore(react): adding prettier and formating files
This commit is contained in:
@@ -11,21 +11,39 @@ export interface IonLifeCycleContextInterface {
|
||||
ionViewDidLeave: () => void;
|
||||
}
|
||||
|
||||
export const IonLifeCycleContext = /*@__PURE__*/React.createContext<IonLifeCycleContextInterface>({
|
||||
onIonViewWillEnter: () => { return; },
|
||||
ionViewWillEnter: () => { return; },
|
||||
onIonViewDidEnter: () => { return; },
|
||||
ionViewDidEnter: () => { return; },
|
||||
onIonViewWillLeave: () => { return; },
|
||||
ionViewWillLeave: () => { return; },
|
||||
onIonViewDidLeave: () => { return; },
|
||||
ionViewDidLeave: () => { return; },
|
||||
export const IonLifeCycleContext = /*@__PURE__*/ React.createContext<IonLifeCycleContextInterface>({
|
||||
onIonViewWillEnter: () => {
|
||||
return;
|
||||
},
|
||||
ionViewWillEnter: () => {
|
||||
return;
|
||||
},
|
||||
onIonViewDidEnter: () => {
|
||||
return;
|
||||
},
|
||||
ionViewDidEnter: () => {
|
||||
return;
|
||||
},
|
||||
onIonViewWillLeave: () => {
|
||||
return;
|
||||
},
|
||||
ionViewWillLeave: () => {
|
||||
return;
|
||||
},
|
||||
onIonViewDidLeave: () => {
|
||||
return;
|
||||
},
|
||||
ionViewDidLeave: () => {
|
||||
return;
|
||||
},
|
||||
});
|
||||
|
||||
export interface LifeCycleCallback { (): void; id?: number; }
|
||||
export interface LifeCycleCallback {
|
||||
(): void;
|
||||
id?: number;
|
||||
}
|
||||
|
||||
export const DefaultIonLifeCycleContext = class implements IonLifeCycleContextInterface {
|
||||
|
||||
ionViewWillEnterCallbacks: LifeCycleCallback[] = [];
|
||||
ionViewDidEnterCallbacks: LifeCycleCallback[] = [];
|
||||
ionViewWillLeaveCallbacks: LifeCycleCallback[] = [];
|
||||
@@ -34,7 +52,7 @@ export const DefaultIonLifeCycleContext = class implements IonLifeCycleContextIn
|
||||
|
||||
onIonViewWillEnter(callback: LifeCycleCallback) {
|
||||
if (callback.id) {
|
||||
const index = this.ionViewWillEnterCallbacks.findIndex(x => x.id === callback.id);
|
||||
const index = this.ionViewWillEnterCallbacks.findIndex((x) => x.id === callback.id);
|
||||
if (index > -1) {
|
||||
this.ionViewWillEnterCallbacks[index] = callback;
|
||||
} else {
|
||||
@@ -46,12 +64,12 @@ export const DefaultIonLifeCycleContext = class implements IonLifeCycleContextIn
|
||||
}
|
||||
|
||||
ionViewWillEnter() {
|
||||
this.ionViewWillEnterCallbacks.forEach(cb => cb());
|
||||
this.ionViewWillEnterCallbacks.forEach((cb) => cb());
|
||||
}
|
||||
|
||||
onIonViewDidEnter(callback: LifeCycleCallback) {
|
||||
if (callback.id) {
|
||||
const index = this.ionViewDidEnterCallbacks.findIndex(x => x.id === callback.id);
|
||||
const index = this.ionViewDidEnterCallbacks.findIndex((x) => x.id === callback.id);
|
||||
if (index > -1) {
|
||||
this.ionViewDidEnterCallbacks[index] = callback;
|
||||
} else {
|
||||
@@ -63,12 +81,12 @@ export const DefaultIonLifeCycleContext = class implements IonLifeCycleContextIn
|
||||
}
|
||||
|
||||
ionViewDidEnter() {
|
||||
this.ionViewDidEnterCallbacks.forEach(cb => cb());
|
||||
this.ionViewDidEnterCallbacks.forEach((cb) => cb());
|
||||
}
|
||||
|
||||
onIonViewWillLeave(callback: LifeCycleCallback) {
|
||||
if (callback.id) {
|
||||
const index = this.ionViewWillLeaveCallbacks.findIndex(x => x.id === callback.id);
|
||||
const index = this.ionViewWillLeaveCallbacks.findIndex((x) => x.id === callback.id);
|
||||
if (index > -1) {
|
||||
this.ionViewWillLeaveCallbacks[index] = callback;
|
||||
} else {
|
||||
@@ -80,12 +98,12 @@ export const DefaultIonLifeCycleContext = class implements IonLifeCycleContextIn
|
||||
}
|
||||
|
||||
ionViewWillLeave() {
|
||||
this.ionViewWillLeaveCallbacks.forEach(cb => cb());
|
||||
this.ionViewWillLeaveCallbacks.forEach((cb) => cb());
|
||||
}
|
||||
|
||||
onIonViewDidLeave(callback: LifeCycleCallback) {
|
||||
if (callback.id) {
|
||||
const index = this.ionViewDidLeaveCallbacks.findIndex(x => x.id === callback.id);
|
||||
const index = this.ionViewDidLeaveCallbacks.findIndex((x) => x.id === callback.id);
|
||||
if (index > -1) {
|
||||
this.ionViewDidLeaveCallbacks[index] = callback;
|
||||
} else {
|
||||
@@ -97,7 +115,7 @@ export const DefaultIonLifeCycleContext = class implements IonLifeCycleContextIn
|
||||
}
|
||||
|
||||
ionViewDidLeave() {
|
||||
this.ionViewDidLeaveCallbacks.forEach(cb => cb());
|
||||
this.ionViewDidLeaveCallbacks.forEach((cb) => cb());
|
||||
this.componentCanBeDestroyed();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,14 @@ export interface NavContextState {
|
||||
getPageManager: () => any;
|
||||
getStackManager: () => any;
|
||||
goBack: (route?: string | RouteInfo, animationBuilder?: AnimationBuilder) => void;
|
||||
navigate: (path: string, direction?: RouterDirection | 'none', ionRouteAction?: 'push' | 'replace' | 'pop', animationBuilder?: AnimationBuilder, options?: any, tab?: string) => void;
|
||||
navigate: (
|
||||
path: string,
|
||||
direction?: RouterDirection | 'none',
|
||||
ionRouteAction?: 'push' | 'replace' | 'pop',
|
||||
animationBuilder?: AnimationBuilder,
|
||||
options?: any,
|
||||
tab?: string
|
||||
) => void;
|
||||
hasIonicRouter: () => boolean;
|
||||
routeInfo?: RouteInfo;
|
||||
setCurrentTab: (tab: string, routeInfo: RouteInfo) => void;
|
||||
@@ -17,14 +24,14 @@ export interface NavContextState {
|
||||
resetTab: (tab: string, originalHref: string, originalRouteOptions?: any) => void;
|
||||
}
|
||||
|
||||
export const NavContext = /*@__PURE__*/React.createContext<NavContextState>({
|
||||
export const NavContext = /*@__PURE__*/ React.createContext<NavContextState>({
|
||||
getIonRedirect: () => undefined,
|
||||
getIonRoute: () => undefined,
|
||||
getPageManager: () => undefined,
|
||||
getStackManager: () => undefined,
|
||||
goBack: (route?: string | RouteInfo) => {
|
||||
if (typeof window !== 'undefined') {
|
||||
if (typeof (route) === 'string') {
|
||||
if (typeof route === 'string') {
|
||||
window.location.pathname = route;
|
||||
} else {
|
||||
window.history.back();
|
||||
@@ -48,5 +55,5 @@ export const NavContext = /*@__PURE__*/React.createContext<NavContextState>({
|
||||
if (typeof window !== 'undefined') {
|
||||
window.location.pathname = path;
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user