1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-25 06:19:22 +00:00
comunicmobile/lib/models/config.dart

76 lines
1.9 KiB
Dart
Raw Normal View History

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