mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-08-26 04:29:40 +00:00
Added flavers env and prod for android and ios including Google services
This commit is contained in:
@ -16,60 +16,55 @@ class AppBarHomeDropdown extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 10, right: 10),
|
||||
child: Center(
|
||||
child: DropdownButton(
|
||||
icon: const Icon(
|
||||
Icons.expand_more,
|
||||
color: ColorsManager.textPrimaryColor,
|
||||
size: 16,
|
||||
),
|
||||
underline: const SizedBox.shrink(),
|
||||
padding: EdgeInsets.zero,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
value: HomeCubit.getInstance().selectedSpace!.id,
|
||||
items: HomeCubit.getInstance().spaces!.map((space) {
|
||||
return DropdownMenuItem(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
value: space.id,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
SvgPicture.asset(
|
||||
Assets.assetsIconsHome,
|
||||
width: 25,
|
||||
height: 25,
|
||||
colorFilter: const ColorFilter.mode(
|
||||
ColorsManager.textPrimaryColor,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
Flexible(
|
||||
fit: FlexFit.loose,
|
||||
child: BodyMedium(
|
||||
text: space.name ?? "??",
|
||||
style: context.bodyMedium.copyWith(
|
||||
fontSize: 15,
|
||||
color: ColorsManager.textPrimaryColor,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
HomeCubit.getInstance().changeSelectedSpace(
|
||||
HomeCubit.getInstance()
|
||||
.spaces!
|
||||
.firstWhere((element) => element.id == value));
|
||||
}
|
||||
},
|
||||
child: DropdownButton(
|
||||
icon: const Icon(
|
||||
Icons.expand_more,
|
||||
color: ColorsManager.textPrimaryColor,
|
||||
size: 16,
|
||||
),
|
||||
underline: const SizedBox.shrink(),
|
||||
padding: EdgeInsets.zero,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
value: HomeCubit.getInstance().selectedSpace!.id,
|
||||
items: HomeCubit.getInstance().spaces!.map((space) {
|
||||
return DropdownMenuItem(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
value: space.id,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
SvgPicture.asset(
|
||||
Assets.assetsIconsHome,
|
||||
width: 25,
|
||||
height: 25,
|
||||
colorFilter: const ColorFilter.mode(
|
||||
ColorsManager.textPrimaryColor,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
Flexible(
|
||||
child: BodyMedium(
|
||||
text: space.name ?? "??",
|
||||
style: context.bodyMedium.copyWith(
|
||||
fontSize: 15,
|
||||
color: ColorsManager.textPrimaryColor,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
HomeCubit.getInstance().changeSelectedSpace(
|
||||
HomeCubit.getInstance().spaces!.firstWhere((element) => element.id == value));
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
|
@ -11,20 +11,18 @@ class DefaultAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<HomeCubit, HomeState>(
|
||||
builder: (context, state) {
|
||||
return Padding(
|
||||
return Container(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 20,
|
||||
),
|
||||
child: AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
leadingWidth: 150,
|
||||
leadingWidth: 200,
|
||||
toolbarHeight: Constants.appBarHeight,
|
||||
leading: HomeCubit.getInstance().spaces!.isNotEmpty
|
||||
? HomeCubit.appBarLeading[
|
||||
HomeCubit.bottomNavItems[HomeCubit.pageIndex].label]
|
||||
? HomeCubit.appBarLeading[HomeCubit.bottomNavItems[HomeCubit.pageIndex].label]!
|
||||
: null,
|
||||
actions: HomeCubit.appBarActions[
|
||||
HomeCubit.bottomNavItems[HomeCubit.pageIndex].label],
|
||||
actions: HomeCubit.appBarActions[HomeCubit.bottomNavItems[HomeCubit.pageIndex].label],
|
||||
));
|
||||
},
|
||||
);
|
||||
|
@ -71,44 +71,49 @@ class ParameterControlDialogState extends State<ParameterControlDialog> {
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_value = (_value - 1).clamp(widget.min, widget.max);
|
||||
});
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.remove,
|
||||
color: Colors.grey,
|
||||
SizedBox(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_value = (_value - 1).clamp(widget.min, widget.max);
|
||||
});
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.remove,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
Slider(
|
||||
value: _value.toDouble(),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_value = value.toInt();
|
||||
});
|
||||
},
|
||||
min: widget.min.toDouble(),
|
||||
max: widget.max.toDouble(),
|
||||
label: _value.toString(),
|
||||
inactiveColor: ColorsManager.greyColor,
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_value = (_value + 1).clamp(widget.min, widget.max);
|
||||
});
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.add,
|
||||
color: Colors.grey,
|
||||
Flexible(
|
||||
child: Slider(
|
||||
value: _value.toDouble(),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_value = value.toInt();
|
||||
});
|
||||
},
|
||||
min: widget.min.toDouble(),
|
||||
max: widget.max.toDouble(),
|
||||
label: _value.toString(),
|
||||
inactiveColor: ColorsManager.greyColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_value = (_value + 1).clamp(widget.min, widget.max);
|
||||
});
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.add,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 1,
|
||||
|
@ -7,6 +7,7 @@ import 'package:syncrow_app/features/menu/view/widgets/profile/profile_tab.dart'
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||
import 'package:syncrow_app/services/locator.dart';
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||
|
||||
@ -33,8 +34,7 @@ class MenuView extends StatelessWidget {
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const BodyMedium(
|
||||
text: String.fromEnvironment('FLAVOR', defaultValue: 'production')),
|
||||
BodyMedium(text: serviceLocator.get<String>()),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
|
@ -1,8 +1,7 @@
|
||||
// File generated by FlutterFire CLI.
|
||||
// ignore_for_file: type=lint
|
||||
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
|
||||
import 'package:flutter/foundation.dart'
|
||||
show defaultTargetPlatform, kIsWeb, TargetPlatform;
|
||||
import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, TargetPlatform;
|
||||
|
||||
/// Default [FirebaseOptions] for use with your Firebase apps.
|
||||
///
|
||||
@ -14,7 +13,7 @@ import 'package:flutter/foundation.dart'
|
||||
/// options: DefaultFirebaseOptions.currentPlatform,
|
||||
/// );
|
||||
/// ```
|
||||
class DefaultFirebaseOptions {
|
||||
class DefaultFirebaseOptionsDev {
|
||||
static FirebaseOptions get currentPlatform {
|
||||
if (kIsWeb) {
|
||||
return web;
|
||||
@ -72,5 +71,4 @@ class DefaultFirebaseOptions {
|
||||
storageBucket: 'test2-8a3d2.appspot.com',
|
||||
measurementId: 'G-Z1RTTTV5H9',
|
||||
);
|
||||
|
||||
}
|
||||
}
|
77
lib/firebase_options_prod.dart
Normal file
77
lib/firebase_options_prod.dart
Normal file
@ -0,0 +1,77 @@
|
||||
// File generated by FlutterFire CLI.
|
||||
// ignore_for_file: type=lint
|
||||
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
|
||||
import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, TargetPlatform;
|
||||
|
||||
/// Default [FirebaseOptions] for use with your Firebase apps.
|
||||
///
|
||||
/// Example:
|
||||
/// ```dart
|
||||
/// import 'firebase_options.dart';
|
||||
/// // ...
|
||||
/// await Firebase.initializeApp(
|
||||
/// options: DefaultFirebaseOptions.currentPlatform,
|
||||
/// );
|
||||
/// ```
|
||||
class DefaultFirebaseOptionsStaging {
|
||||
static FirebaseOptions get currentPlatform {
|
||||
if (kIsWeb) {
|
||||
return web;
|
||||
}
|
||||
switch (defaultTargetPlatform) {
|
||||
case TargetPlatform.android:
|
||||
return android;
|
||||
case TargetPlatform.iOS:
|
||||
return ios;
|
||||
case TargetPlatform.macOS:
|
||||
throw UnsupportedError(
|
||||
'DefaultFirebaseOptions have not been configured for macos - '
|
||||
'you can reconfigure this by running the FlutterFire CLI again.',
|
||||
);
|
||||
case TargetPlatform.windows:
|
||||
throw UnsupportedError(
|
||||
'DefaultFirebaseOptions have not been configured for windows - '
|
||||
'you can reconfigure this by running the FlutterFire CLI again.',
|
||||
);
|
||||
case TargetPlatform.linux:
|
||||
throw UnsupportedError(
|
||||
'DefaultFirebaseOptions have not been configured for linux - '
|
||||
'you can reconfigure this by running the FlutterFire CLI again.',
|
||||
);
|
||||
default:
|
||||
throw UnsupportedError(
|
||||
'DefaultFirebaseOptions are not supported for this platform.',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static const FirebaseOptions android = FirebaseOptions(
|
||||
apiKey: 'AIzaSyDP9GpYfLE8gHTj3kZ1hW8fx_FkJqOqSQk',
|
||||
appId: '1:786692570726:android:0ef7079c2b978d4417b7a7',
|
||||
messagingSenderId: '786692570726',
|
||||
projectId: 'syncrow-staging',
|
||||
databaseURL: 'https://syncrow-staging-default-rtdb.firebaseio.com',
|
||||
storageBucket: 'syncrow-staging.appspot.com',
|
||||
);
|
||||
|
||||
static const FirebaseOptions ios = FirebaseOptions(
|
||||
apiKey: 'AIzaSyAWlRiuJ75FMlf2_UDdri1voWKvkaSHtRg',
|
||||
appId: '1:786692570726:ios:455a6fcff77e130f17b7a7',
|
||||
messagingSenderId: '786692570726',
|
||||
projectId: 'syncrow-staging',
|
||||
databaseURL: 'https://syncrow-staging-default-rtdb.firebaseio.com',
|
||||
storageBucket: 'syncrow-staging.appspot.com',
|
||||
iosBundleId: 'com.example.syncrow.app',
|
||||
);
|
||||
|
||||
static const FirebaseOptions web = FirebaseOptions(
|
||||
apiKey: 'AIzaSyDyGaQ3sZhb4meaY6sGke-YglhdhJ2is8Q',
|
||||
appId: '1:786692570726:web:93c931e6701797b317b7a7',
|
||||
messagingSenderId: '786692570726',
|
||||
projectId: 'syncrow-staging',
|
||||
authDomain: 'syncrow-staging.firebaseapp.com',
|
||||
databaseURL: 'https://syncrow-staging-default-rtdb.firebaseio.com',
|
||||
storageBucket: 'syncrow-staging.appspot.com',
|
||||
measurementId: 'G-CZ3J3G6LMQ',
|
||||
);
|
||||
}
|
@ -3,19 +3,20 @@ import 'package:firebase_core/firebase_core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:syncrow_app/firebase_options.dart';
|
||||
import 'package:syncrow_app/firebase_options_prod.dart';
|
||||
import 'package:syncrow_app/services/locator.dart';
|
||||
import 'package:syncrow_app/utils/bloc_observer.dart';
|
||||
import 'package:syncrow_app/utils/helpers/localization_helpers.dart';
|
||||
import 'my_app.dart';
|
||||
|
||||
void main() {
|
||||
//to observe the state of the blocs in the output console
|
||||
Bloc.observer = MyBlocObserver();
|
||||
//to catch all the errors in the app and send them to firebase
|
||||
runZonedGuarded(() async {
|
||||
//to load the environment variables
|
||||
const environment = String.fromEnvironment('FLAVOR', defaultValue: 'production');
|
||||
await dotenv.load(fileName: '.env.$environment');
|
||||
// const environment = String.fromEnvironment('FLAVOR', defaultValue: 'prod');
|
||||
await dotenv.load(fileName: '.env.prod');
|
||||
|
||||
// //this is to make the app work with the self-signed certificate
|
||||
// HttpOverrides.global = MyHttpOverrides();
|
||||
@ -29,11 +30,10 @@ void main() {
|
||||
// });
|
||||
|
||||
//to initialize the locator
|
||||
initialSetup();
|
||||
initialSetup(envName: 'prod');
|
||||
|
||||
await Firebase.initializeApp(
|
||||
name: 'test2',
|
||||
options: DefaultFirebaseOptions.currentPlatform,
|
||||
options: DefaultFirebaseOptionsStaging.currentPlatform,
|
||||
);
|
||||
|
||||
//final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
|
49
lib/main_dev.dart
Normal file
49
lib/main_dev.dart
Normal file
@ -0,0 +1,49 @@
|
||||
import 'dart:async';
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:syncrow_app/firebase_options_dev.dart';
|
||||
import 'package:syncrow_app/services/locator.dart';
|
||||
import 'package:syncrow_app/utils/bloc_observer.dart';
|
||||
import 'package:syncrow_app/utils/helpers/localization_helpers.dart';
|
||||
import 'my_app.dart';
|
||||
|
||||
void main() {
|
||||
//to observe the state of the blocs in the output console
|
||||
Bloc.observer = MyBlocObserver();
|
||||
//to catch all the errors in the app and send them to firebase
|
||||
runZonedGuarded(() async {
|
||||
//to load the environment variables
|
||||
// const environment = String.fromEnvironment('FLAVOR', defaultValue: 'prod');
|
||||
await dotenv.load(fileName: '.env.dev');
|
||||
|
||||
// //this is to make the app work with the self-signed certificate
|
||||
// HttpOverrides.global = MyHttpOverrides();
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
//license for the font
|
||||
// LicenseRegistry.addLicense(() async* {
|
||||
// final license =
|
||||
// await rootBundle.loadString('assets/fonts/roboto/LICENSE.txt');
|
||||
// yield LicenseEntryWithLineBreaks(['google_fonts'], license);
|
||||
// });
|
||||
|
||||
//to initialize the locator
|
||||
initialSetup(envName: 'dev');
|
||||
|
||||
await Firebase.initializeApp(
|
||||
options: DefaultFirebaseOptionsDev.currentPlatform,
|
||||
);
|
||||
|
||||
//final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
|
||||
//to save the locale in the shared preferences
|
||||
await LocalizationService.saveLocale(const Locale("en", "AE"));
|
||||
final savedLocale = await LocalizationService.savedLocale();
|
||||
|
||||
runApp(MyApp(savedLocale));
|
||||
}, (error, stackTrace) {
|
||||
// FirebaseCrashlytics.instance.recordError(error, stackTrace, fatal: true);
|
||||
});
|
||||
}
|
@ -5,9 +5,9 @@ import 'package:syncrow_app/services/api/http_service.dart';
|
||||
|
||||
final GetIt serviceLocator = GetIt.instance;
|
||||
// setupLocator() // to search for dependency injection in flutter
|
||||
initialSetup() {
|
||||
initialSetup({required String envName}) {
|
||||
serviceLocator.registerSingleton<HTTPInterceptor>(HTTPInterceptor());
|
||||
//Base classes
|
||||
|
||||
serviceLocator.registerSingleton<Dio>(HTTPService.setupDioClient());
|
||||
serviceLocator.registerSingleton<String>(envName);
|
||||
}
|
||||
|
Reference in New Issue
Block a user