import 'package:flutter/material.dart';
import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/core/enums/dev_mode.dart';

abstract class Flavor {
  Flavor._({
    this.banner,
    this.bannerColor = Colors.red,
    this.devMode,
  }) {
    _instance = this;
  }

  static Flavor? _instance;

  final String? banner;
  final Color bannerColor;
  final DevMode? devMode;

  /// Returns [Flavor] instance.
  static Flavor get() {
    if (_instance == null) {
      throw Exception('Flavor not initialized!');
    }

    return _instance!;
  }

  @override
  String toString() => runtimeType.toString().replaceAll('Flavor', '');
}

class DevelopmentFlavor extends Flavor {
  factory DevelopmentFlavor() {
    const modeString = String.fromEnvironment('dev_mode', defaultValue: 'mock');
    final mode = DevMode.fromString(modeString);

    return DevelopmentFlavor._(devMode: mode);
  }
  DevelopmentFlavor._({
    required DevMode devMode,
  }) : super._(
          banner: 'Dev',
          devMode: devMode,
        );
}

class StagingFlavor extends Flavor {
  StagingFlavor()
      : super._(
          banner: 'Staging',
          bannerColor: Colors.green,
        );
}

class ProductionFlavor extends Flavor {
  ProductionFlavor() : super._();
}
