基础库
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

48 lines
1.3 KiB

  1. import 'package:flutter/material.dart';
  2. import 'package:zhiying_comm/zhiying_comm.dart';
  3. class FNNavigatorObserver extends NavigatorObserver {
  4. factory FNNavigatorObserver() => _getInstance();
  5. static FNNavigatorObserver get instance => _getInstance();
  6. static FNNavigatorObserver _instance;
  7. NavigatorObserver curContext;
  8. FNNavigatorObserver._();
  9. static FNNavigatorObserver _getInstance() {
  10. if (_instance == null) {
  11. _instance = new FNNavigatorObserver._();
  12. }
  13. return _instance;
  14. }
  15. String topRouteName = "";
  16. void didPush(Route<dynamic> route, Route<dynamic> previousRoute) {
  17. notifyHide(previousRoute);
  18. notifyShow(route);
  19. NativeUtil.onPagePush(previousRoute == null ? true : previousRoute.isFirst);
  20. }
  21. void didPop(Route<dynamic> route, Route<dynamic> previousRoute) {
  22. notifyHide(route);
  23. notifyShow(previousRoute);
  24. NativeUtil.onPagePush(previousRoute == null ? true : previousRoute.isFirst);
  25. }
  26. void didRemove(Route<dynamic> route, Route<dynamic> previousRoute) {
  27. notifyHide(route);
  28. notifyShow(previousRoute);
  29. }
  30. /// The [Navigator] replaced `oldRoute` with `newRoute`.
  31. void didReplace({Route<dynamic> newRoute, Route<dynamic> oldRoute}) {
  32. notifyHide(oldRoute);
  33. notifyShow(newRoute);
  34. }
  35. void notifyShow(Route<dynamic> route) {}
  36. void notifyHide(Route<dynamic> route) {}
  37. }