import 'package:flutter/material.dart';
import 'package:habo/navigation/app_router.dart';
import 'package:habo/navigation/routes.dart';

class HaboRouteInformationParser extends RouteInformationParser<HaboRouteConfiguration> {
  @override
  Future<HaboRouteConfiguration> parseRouteInformation(RouteInformation routeInformation) async {
    final uri = routeInformation.uri;
    return HaboRouteConfiguration(path: uri.path.isEmpty ? RouteConstants.habitsPath : uri.path);
  }

  @override
  RouteInformation restoreRouteInformation(HaboRouteConfiguration configuration) {
    return RouteInformation(uri: Uri.parse(configuration.path));
  }
}
