import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:news_getx/data/services/config.dart';
import 'package:news_getx/data/services/user.dart';
import 'package:news_getx/routes/app_pages.dart';


/// 第一次欢迎页面
class RouteWelcomeMiddleware extends GetMiddleware {
  // priority 数字小优先级高
  @override
  int? priority = 0;

  RouteWelcomeMiddleware({this.priority});

  @override
  RouteSettings? redirect(String? route) {
    if (ConfigService.to.isFirstOpen == true) {
      return null;
    } else if (UserService.to.isLogin == true) {
      return RouteSettings(name: AppRoutes.Application);
    } else {
      return RouteSettings(name: AppRoutes.Signin);
    }
  }
}