import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:keyboard/module/login/login_page.dart';
import 'package:keyboard/module/store/store_page.dart';

class NavigationHandler {
  static final NavigationHandler _instance = NavigationHandler._internal();
  factory NavigationHandler() => _instance;
  NavigationHandler._internal();

  static const MethodChannel _channel = MethodChannel('keyboard_ios');

  static void initialize() {
    _channel.setMethodCallHandler(_handleMethod);
  }

  static Future<dynamic> _handleMethod(MethodCall call) async {
    switch (call.method) {
      case 'navigateToLogin':
        LoginPage.start();
        break;
      case 'navigateToMember':
        StorePage.start();
        break;
      default:
        throw PlatformException(
          code: 'Unimplemented',
          details: '未实现的方法: ${call.method}',
        );
    }
  }
}