2021-04-23 18:11:17 +02:00
|
|
|
import 'package:comunic/ui/routes/tour_route.dart';
|
2021-04-24 09:16:29 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2019-04-22 19:16:26 +02:00
|
|
|
|
|
|
|
/// Application configuration model
|
|
|
|
///
|
|
|
|
/// @author Pierre HUBERT
|
|
|
|
|
2021-04-12 19:26:05 +02:00
|
|
|
const defaultColor = Color(0xFF1A237E);
|
|
|
|
|
2019-04-22 19:16:26 +02:00
|
|
|
/// Configuration class
|
|
|
|
class Config {
|
|
|
|
final String apiServerName;
|
|
|
|
final String apiServerUri;
|
|
|
|
final bool apiServerSecure;
|
2021-02-13 16:03:07 +01:00
|
|
|
final String clientName;
|
2021-04-24 09:16:29 +02:00
|
|
|
|
|
|
|
// Theme customization
|
2021-04-12 19:26:05 +02:00
|
|
|
final Color splashBackgroundColor;
|
2022-03-10 19:39:57 +01:00
|
|
|
final Color? primaryColor;
|
|
|
|
final Color? primaryColorDark;
|
2021-04-23 12:24:35 +02:00
|
|
|
final String appName;
|
2022-03-10 19:39:57 +01:00
|
|
|
final String? appQuickDescription;
|
|
|
|
final Color? unreadConversationColor;
|
|
|
|
final Color? defaultConversationColor;
|
2021-02-13 16:03:07 +01:00
|
|
|
|
2021-04-23 18:11:17 +02:00
|
|
|
// Entries for the welcome tour
|
2022-03-10 19:39:57 +01:00
|
|
|
final TourEntriesBuilder? toursEntriesBuilder;
|
2021-04-23 18:11:17 +02:00
|
|
|
|
2021-04-24 10:14:56 +02:00
|
|
|
// Custom initialization
|
2022-03-10 19:39:57 +01:00
|
|
|
final Future<void> Function()? additionalLoading;
|
2021-04-24 10:14:56 +02:00
|
|
|
|
2021-04-24 09:16:29 +02:00
|
|
|
// Custom main application route
|
2022-03-10 19:39:57 +01:00
|
|
|
final Widget Function(BuildContext, GlobalKey)? mainRouteBuilder;
|
2021-04-24 09:16:29 +02:00
|
|
|
|
2019-11-02 18:16:16 +01:00
|
|
|
const Config({
|
2022-03-10 19:39:57 +01:00
|
|
|
required this.apiServerName,
|
|
|
|
required this.apiServerUri,
|
|
|
|
required this.apiServerSecure,
|
|
|
|
required this.clientName,
|
2021-04-12 19:26:05 +02:00
|
|
|
this.splashBackgroundColor = defaultColor,
|
2021-04-24 08:57:20 +02:00
|
|
|
this.primaryColor,
|
|
|
|
this.primaryColorDark,
|
2021-04-23 12:24:35 +02:00
|
|
|
this.appName = "Comunic",
|
2021-04-23 12:28:50 +02:00
|
|
|
this.appQuickDescription,
|
2021-04-25 16:35:50 +02:00
|
|
|
this.defaultConversationColor,
|
2021-04-25 16:24:42 +02:00
|
|
|
this.unreadConversationColor,
|
2021-04-23 18:11:17 +02:00
|
|
|
this.toursEntriesBuilder,
|
2021-04-24 10:14:56 +02:00
|
|
|
this.additionalLoading,
|
2021-04-24 09:16:29 +02:00
|
|
|
this.mainRouteBuilder,
|
2022-03-10 20:36:55 +01:00
|
|
|
});
|
2019-04-22 19:16:26 +02:00
|
|
|
|
|
|
|
/// Get and set static configuration
|
2022-03-10 19:39:57 +01:00
|
|
|
static Config? _config;
|
2019-04-22 19:16:26 +02:00
|
|
|
|
2022-03-10 19:39:57 +01:00
|
|
|
static Config? get() {
|
2019-04-22 19:16:26 +02:00
|
|
|
return _config;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set(Config conf) {
|
|
|
|
_config = conf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Get the current configuration of the application
|
2022-03-10 19:39:57 +01:00
|
|
|
Config config() {
|
|
|
|
return Config.get()!;
|
2019-04-22 19:16:26 +02:00
|
|
|
}
|