Skip to content

Commit 4657aa9

Browse files
authored
Merge pull request #5 from ersinaksar/feature/initial-setup
Feature/initial setup
2 parents 25592d1 + d06eb15 commit 4657aa9

36 files changed

+1431
-50
lines changed

ios/Podfile

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Uncomment this line to define a global platform for your project
2+
# platform :ios, '12.0'
3+
4+
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
5+
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
6+
7+
project 'Runner', {
8+
'Debug' => :debug,
9+
'Profile' => :release,
10+
'Release' => :release,
11+
}
12+
13+
def flutter_root
14+
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
15+
unless File.exist?(generated_xcode_build_settings_path)
16+
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
17+
end
18+
19+
File.foreach(generated_xcode_build_settings_path) do |line|
20+
matches = line.match(/FLUTTER_ROOT\=(.*)/)
21+
return matches[1].strip if matches
22+
end
23+
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
24+
end
25+
26+
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
27+
28+
flutter_ios_podfile_setup
29+
30+
target 'Runner' do
31+
use_frameworks!
32+
use_modular_headers!
33+
34+
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
35+
target 'RunnerTests' do
36+
inherit! :search_paths
37+
end
38+
end
39+
40+
post_install do |installer|
41+
installer.pods_project.targets.each do |target|
42+
flutter_additional_ios_build_settings(target)
43+
end
44+
end

ios/Podfile.lock

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
PODS:
2+
- connectivity_plus (0.0.1):
3+
- Flutter
4+
- FlutterMacOS
5+
- Firebase/CoreOnly (10.25.0):
6+
- FirebaseCore (= 10.25.0)
7+
- Firebase/Messaging (10.25.0):
8+
- Firebase/CoreOnly
9+
- FirebaseMessaging (~> 10.25.0)
10+
- firebase_core (2.32.0):
11+
- Firebase/CoreOnly (= 10.25.0)
12+
- Flutter
13+
- firebase_messaging (14.7.10):
14+
- Firebase/Messaging (= 10.25.0)
15+
- firebase_core
16+
- Flutter
17+
- FirebaseCore (10.25.0):
18+
- FirebaseCoreInternal (~> 10.0)
19+
- GoogleUtilities/Environment (~> 7.12)
20+
- GoogleUtilities/Logger (~> 7.12)
21+
- FirebaseCoreInternal (10.29.0):
22+
- "GoogleUtilities/NSData+zlib (~> 7.8)"
23+
- FirebaseInstallations (10.29.0):
24+
- FirebaseCore (~> 10.0)
25+
- GoogleUtilities/Environment (~> 7.8)
26+
- GoogleUtilities/UserDefaults (~> 7.8)
27+
- PromisesObjC (~> 2.1)
28+
- FirebaseMessaging (10.25.0):
29+
- FirebaseCore (~> 10.0)
30+
- FirebaseInstallations (~> 10.0)
31+
- GoogleDataTransport (~> 9.3)
32+
- GoogleUtilities/AppDelegateSwizzler (~> 7.8)
33+
- GoogleUtilities/Environment (~> 7.8)
34+
- GoogleUtilities/Reachability (~> 7.8)
35+
- GoogleUtilities/UserDefaults (~> 7.8)
36+
- nanopb (< 2.30911.0, >= 2.30908.0)
37+
- Flutter (1.0.0)
38+
- GoogleDataTransport (9.4.1):
39+
- GoogleUtilities/Environment (~> 7.7)
40+
- nanopb (< 2.30911.0, >= 2.30908.0)
41+
- PromisesObjC (< 3.0, >= 1.2)
42+
- GoogleUtilities/AppDelegateSwizzler (7.13.3):
43+
- GoogleUtilities/Environment
44+
- GoogleUtilities/Logger
45+
- GoogleUtilities/Network
46+
- GoogleUtilities/Privacy
47+
- GoogleUtilities/Environment (7.13.3):
48+
- GoogleUtilities/Privacy
49+
- PromisesObjC (< 3.0, >= 1.2)
50+
- GoogleUtilities/Logger (7.13.3):
51+
- GoogleUtilities/Environment
52+
- GoogleUtilities/Privacy
53+
- GoogleUtilities/Network (7.13.3):
54+
- GoogleUtilities/Logger
55+
- "GoogleUtilities/NSData+zlib"
56+
- GoogleUtilities/Privacy
57+
- GoogleUtilities/Reachability
58+
- "GoogleUtilities/NSData+zlib (7.13.3)":
59+
- GoogleUtilities/Privacy
60+
- GoogleUtilities/Privacy (7.13.3)
61+
- GoogleUtilities/Reachability (7.13.3):
62+
- GoogleUtilities/Logger
63+
- GoogleUtilities/Privacy
64+
- GoogleUtilities/UserDefaults (7.13.3):
65+
- GoogleUtilities/Logger
66+
- GoogleUtilities/Privacy
67+
- nanopb (2.30910.0):
68+
- nanopb/decode (= 2.30910.0)
69+
- nanopb/encode (= 2.30910.0)
70+
- nanopb/decode (2.30910.0)
71+
- nanopb/encode (2.30910.0)
72+
- package_info_plus (0.4.5):
73+
- Flutter
74+
- PromisesObjC (2.4.0)
75+
- Sentry/HybridSDK (8.40.1)
76+
- sentry_flutter (8.10.1):
77+
- Flutter
78+
- FlutterMacOS
79+
- Sentry/HybridSDK (= 8.40.1)
80+
81+
DEPENDENCIES:
82+
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/darwin`)
83+
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
84+
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
85+
- Flutter (from `Flutter`)
86+
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
87+
- sentry_flutter (from `.symlinks/plugins/sentry_flutter/ios`)
88+
89+
SPEC REPOS:
90+
trunk:
91+
- Firebase
92+
- FirebaseCore
93+
- FirebaseCoreInternal
94+
- FirebaseInstallations
95+
- FirebaseMessaging
96+
- GoogleDataTransport
97+
- GoogleUtilities
98+
- nanopb
99+
- PromisesObjC
100+
- Sentry
101+
102+
EXTERNAL SOURCES:
103+
connectivity_plus:
104+
:path: ".symlinks/plugins/connectivity_plus/darwin"
105+
firebase_core:
106+
:path: ".symlinks/plugins/firebase_core/ios"
107+
firebase_messaging:
108+
:path: ".symlinks/plugins/firebase_messaging/ios"
109+
Flutter:
110+
:path: Flutter
111+
package_info_plus:
112+
:path: ".symlinks/plugins/package_info_plus/ios"
113+
sentry_flutter:
114+
:path: ".symlinks/plugins/sentry_flutter/ios"
115+
116+
SPEC CHECKSUMS:
117+
connectivity_plus: 4c41c08fc6d7c91f63bc7aec70ffe3730b04f563
118+
Firebase: 0312a2352584f782ea56f66d91606891d4607f06
119+
firebase_core: a626d00494efa398e7c54f25f1454a64c8abf197
120+
firebase_messaging: 1541105e2a2a6ef8bd869bcc44157d31e82f3a50
121+
FirebaseCore: 7ec4d0484817f12c3373955bc87762d96842d483
122+
FirebaseCoreInternal: df84dd300b561c27d5571684f389bf60b0a5c934
123+
FirebaseInstallations: 913cf60d0400ebd5d6b63a28b290372ab44590dd
124+
FirebaseMessaging: 88950ba9485052891ebe26f6c43a52bb62248952
125+
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
126+
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
127+
GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15
128+
nanopb: 438bc412db1928dac798aa6fd75726007be04262
129+
package_info_plus: c0502532a26c7662a62a356cebe2692ec5fe4ec4
130+
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
131+
Sentry: e9215d7b17f7902692b4f8700e061e4f853e3521
132+
sentry_flutter: 927eed60d66951d1b0f1db37fe94ff5cb7c80231
133+
134+
PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796
135+
136+
COCOAPODS: 1.15.2

lib/app/app.dart

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import 'package:flutter/material.dart';
2-
import 'config/app_config.dart';
2+
import 'package:flutter_riverpod/flutter_riverpod.dart';
3+
4+
import '../core/providers/app_config_provider.dart';
35
import 'navigation/app_router.dart';
46

5-
class StructureApp extends StatelessWidget {
7+
class StructureApp extends ConsumerWidget {
68
const StructureApp({Key? key}) : super(key: key);
79

810
@override
9-
Widget build(BuildContext context) {
11+
Widget build(BuildContext context, WidgetRef ref) {
12+
final appConfig = ref.watch(appConfigProvider);
1013
return MaterialApp.router(
11-
title: AppConfig.appName,
12-
theme: AppConfig.themeData,
14+
title: appConfig.appName,
15+
theme: appConfig.themeData,
1316
routerConfig: appRouter,
1417
);
1518
}

lib/app/config/app_config.dart

+156-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,161 @@
1+
import 'dart:io';
2+
3+
import 'package:data_connection_checker_tv/data_connection_checker.dart';
4+
import 'package:flutter/foundation.dart';
15
import 'package:flutter/material.dart';
6+
import 'package:package_info_plus/package_info_plus.dart';
7+
8+
import '../../core/constants/app_constants.dart';
9+
import '../../core/networking/network_info.dart';
10+
import 'platform_config.dart';
11+
12+
enum Flavor { prod, test, dev }
13+
14+
enum PlatformType { web, ios, android, macos, linux, windows }
215

316
class AppConfig {
4-
static const String appName = 'Structure App';
17+
/// Platform-specific configuration
18+
final Flavor flavor;
19+
final String appName;
20+
final String baseUrl;
21+
final String sentryUrl;
22+
final PlatformConfig platformConfig;
23+
24+
/// Common settings across all environments
25+
final String pubnubPublishKey = PUBNUB_PUBLISH_KEY;
26+
final String pubnubSecretKey = PUBNUB_SECRET_KEY;
27+
final String bucket = BUCKET;
28+
final String identifier = IDENTIFIER;
29+
final String secret = SECRET;
30+
final String regIdentifier = REG_IDENTIFIER;
31+
final String regSecret = REG_SECRET;
32+
33+
final ThemeData themeData;
34+
35+
static late AppConfig shared; // Singleton AppConfig
36+
static late NetworkInfo networkInfo;
37+
static bool isOnline = false;
38+
39+
/// Private constructor for AppConfig
40+
AppConfig._internal({
41+
required this.flavor,
42+
required this.appName,
43+
required this.baseUrl,
44+
required this.sentryUrl,
45+
required this.platformConfig,
46+
required this.themeData,
47+
});
48+
49+
/// Factory method to create an AppConfig based on environment and platform
50+
factory AppConfig.create({required Flavor flavor}) {
51+
PlatformType platformType = detectPlatform();
52+
PlatformConfig platformConfig;
53+
54+
/// Select platform-specific configuration
55+
switch (platformType) {
56+
case PlatformType.web:
57+
platformConfig = PlatformConfig.web();
58+
break;
59+
case PlatformType.ios:
60+
platformConfig = PlatformConfig.ios();
61+
break;
62+
case PlatformType.android:
63+
platformConfig = PlatformConfig.android();
64+
break;
65+
case PlatformType.macos:
66+
platformConfig = PlatformConfig.macos();
67+
break;
68+
case PlatformType.linux:
69+
platformConfig = PlatformConfig.linux();
70+
break;
71+
case PlatformType.windows:
72+
platformConfig = PlatformConfig.windows();
73+
break;
74+
default:
75+
throw UnsupportedError("Unsupported Platform");
76+
}
77+
78+
/// Return environment-specific configuration with the selected platform configuration
79+
switch (flavor) {
80+
case Flavor.dev:
81+
shared = AppConfig._dev(platformConfig);
82+
break;
83+
case Flavor.prod:
84+
shared = AppConfig._prod(platformConfig);
85+
break;
86+
case Flavor.test:
87+
shared = AppConfig._test(platformConfig);
88+
break;
89+
default:
90+
throw UnsupportedError("Unsupported Flavor");
91+
}
92+
93+
// Start the NetworkInfo
94+
networkInfo = NetworkInfoImpl(DataConnectionChecker());
95+
96+
return shared;
97+
}
98+
99+
/// Private constructor for dev environment
100+
AppConfig._dev(PlatformConfig platformConfig)
101+
: flavor = Flavor.dev,
102+
appName = APP_NAME_DEV,
103+
baseUrl = BASE_URL_DEV,
104+
sentryUrl = SENTRY_URL_DEV,
105+
platformConfig = platformConfig,
106+
themeData = ThemeData(
107+
primarySwatch: Colors.blue,
108+
);
109+
110+
/// Private constructor for production environment
111+
AppConfig._prod(PlatformConfig platformConfig)
112+
: flavor = Flavor.prod,
113+
appName = APP_NAME_PROD,
114+
baseUrl = BASE_URL_PROD,
115+
sentryUrl = SENTRY_URL_PROD,
116+
platformConfig = platformConfig,
117+
themeData = ThemeData(
118+
primarySwatch: Colors.green,
119+
);
120+
121+
// Private constructor for test environment
122+
AppConfig._test(PlatformConfig platformConfig)
123+
: flavor = Flavor.test,
124+
appName = APP_NAME_TEST,
125+
baseUrl = BASE_URL_TEST,
126+
sentryUrl = SENTRY_URL_TEST,
127+
platformConfig = platformConfig,
128+
themeData = ThemeData(
129+
primarySwatch: Colors.orange,
130+
);
131+
132+
// internet connection control function
133+
static Future<bool> checkOnlineStatus() async {
134+
isOnline = await networkInfo.isConnected;
135+
return isOnline;
136+
}
137+
138+
// application version control function
139+
static Future<String> checkAppVersion() async {
140+
PackageInfo packageInfo = await PackageInfo.fromPlatform();
141+
return packageInfo.version;
142+
}
143+
}
5144

6-
static ThemeData themeData = ThemeData(
7-
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
8-
useMaterial3: true,
9-
);
145+
PlatformType detectPlatform() {
146+
if (kIsWeb) {
147+
return PlatformType.web;
148+
} else if (Platform.isIOS) {
149+
return PlatformType.ios;
150+
} else if (Platform.isAndroid) {
151+
return PlatformType.android;
152+
} else if (Platform.isMacOS) {
153+
return PlatformType.macos;
154+
} else if (Platform.isLinux) {
155+
return PlatformType.linux;
156+
} else if (Platform.isWindows) {
157+
return PlatformType.windows;
158+
} else {
159+
throw UnsupportedError("Unsupported Platform");
160+
}
10161
}

0 commit comments

Comments
 (0)