Skip to content

Commit

Permalink
api fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
z4roc committed Feb 3, 2023
1 parent aef5da7 commit c816a41
Show file tree
Hide file tree
Showing 16 changed files with 464 additions and 31 deletions.
39 changes: 39 additions & 0 deletions android/app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"project_info": {
"project_number": "72220156624",
"project_id": "valstore-c6e9a",
"storage_bucket": "valstore-c6e9a.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:72220156624:android:296d995dc24c112e54b4d5",
"android_client_info": {
"package_name": "com.example.valstore"
}
},
"oauth_client": [
{
"client_id": "72220156624-0jo8lcnfnjsjiv9921c2ev2p941gajl3.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyCgrHLToYINvfWZ7c2AmFyFMxeAvO7u7jU"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "72220156624-0jo8lcnfnjsjiv9921c2ev2p941gajl3.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}
34 changes: 34 additions & 0 deletions ios/Runner/GoogleService-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CLIENT_ID</key>
<string>72220156624-l02llpjonnn9p6thnutr1gvubo3fiktp.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.72220156624-l02llpjonnn9p6thnutr1gvubo3fiktp</string>
<key>API_KEY</key>
<string>AIzaSyBULY3zyp24hgD4vyOVLiY7KDX2JHwzTeM</string>
<key>GCM_SENDER_ID</key>
<string>72220156624</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.example.valstore</string>
<key>PROJECT_ID</key>
<string>valstore-c6e9a</string>
<key>STORAGE_BUCKET</key>
<string>valstore-c6e9a.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:72220156624:ios:ef512fcf52d434ab54b4d5</string>
</dict>
</plist>
7 changes: 7 additions & 0 deletions ios/firebase_app_id_file.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"file_generated_by": "FlutterFire CLI",
"purpose": "FirebaseAppID & ProjectID for this Firebase app in this directory",
"GOOGLE_APP_ID": "1:72220156624:ios:ef512fcf52d434ab54b4d5",
"FIREBASE_PROJECT_ID": "valstore-c6e9a",
"GCM_SENDER_ID": "72220156624"
}
13 changes: 13 additions & 0 deletions lib/color_extension.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'package:flutter/material.dart';

class HexColor extends Color {
static int _getColorFromHex(String hexColor) {
hexColor = hexColor.toUpperCase().replaceAll("#", "");
if (hexColor.length == 6) {
hexColor = "FF" + hexColor;
}
return int.parse(hexColor, radix: 16);
}

HexColor(final String hexColor) : super(_getColorFromHex(hexColor));
}
69 changes: 69 additions & 0 deletions lib/firebase_options.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// File generated by FlutterFire CLI.
// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members
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 DefaultFirebaseOptions {
static FirebaseOptions get currentPlatform {
if (kIsWeb) {
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for web - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
}
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: 'AIzaSyCgrHLToYINvfWZ7c2AmFyFMxeAvO7u7jU',
appId: '1:72220156624:android:296d995dc24c112e54b4d5',
messagingSenderId: '72220156624',
projectId: 'valstore-c6e9a',
storageBucket: 'valstore-c6e9a.appspot.com',
);

static const FirebaseOptions ios = FirebaseOptions(
apiKey: 'AIzaSyBULY3zyp24hgD4vyOVLiY7KDX2JHwzTeM',
appId: '1:72220156624:ios:ef512fcf52d434ab54b4d5',
messagingSenderId: '72220156624',
projectId: 'valstore-c6e9a',
storageBucket: 'valstore-c6e9a.appspot.com',
iosClientId: '72220156624-l02llpjonnn9p6thnutr1gvubo3fiktp.apps.googleusercontent.com',
iosBundleId: 'com.example.valstore',
);
}
7 changes: 6 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:valstore/firebase_options.dart';
import 'package:valstore/routes.dart';
import 'package:valstore/theme.dart';

void main() {
void main() async {
runApp(const MyApp());
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
}

final navigatorKey = GlobalKey<NavigatorState>();
Expand Down
2 changes: 1 addition & 1 deletion lib/models/bundle_display_data.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:valstore/models/ValApiBundle.dart';
import 'package:valstore/models/val_api_bundle.dart';
import 'package:valstore/models/bundle.dart';

class BundleDisplayData {
Expand Down
115 changes: 115 additions & 0 deletions lib/models/firebase_skin.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
class FirebaseSkin {
String? name;
String? offerId;
String? skinId;
List<Chroma>? chromas;
List<Level>? levels;
int? cost;
String? icon;
ContentTier? contentTier;

FirebaseSkin(
{this.name,
this.offerId,
this.skinId,
this.cost,
this.icon,
this.contentTier,
this.chromas,
this.levels});

FirebaseSkin.fromJson(Map<String, dynamic> json) {
name = json['name'];
offerId = json['offer_id'];
skinId = json['skin_id'];
cost = json['cost'];
icon = json['icon'];
contentTier = json['content_tier'] != null
? ContentTier.fromJson(json['content_tier'])
: null;
if (json['chromas'] != null) {
chromas = <Chroma>[];
json['chromas'].forEach((c) {
chromas!.add(Chroma.fromJson(c));
});
}
if (json['levels'] != null) {
levels = <Level>[];
json['levels'].forEach((c) {
levels!.add(Level.fromJson(c));
});
}
}
}

class ContentTier {
String? name;
String? color;
String? icon;

ContentTier({this.name, this.color, this.icon});

ContentTier.fromJson(Map<String, dynamic> json) {
name = json['name'];
color = json['color'];
icon = json['icon'];
}
}

class Chroma {
String? assetPath;
String? displayIcon;
String? displayName;
String? fullRender;
String? streamedVideo;
String? swatch;
String? uuid;

Chroma(
{this.assetPath,
this.displayIcon,
this.displayName,
this.fullRender,
this.streamedVideo,
this.swatch,
this.uuid});

Chroma.fromJson(Map<String, dynamic> json) {
assetPath = json['assetPath'];
displayIcon = json['displayIcon'];
displayName = json['displayName'];
fullRender = json['fullRender'];
streamedVideo = json['streamedVideo'];
swatch = json['swatch'];
uuid = json['uuid'];
}
}

class Level {
String? assetPath;
String? displayIcon;
String? displayName;
String? fullRender;
String? streamedVideo;
String? swatch;
String? uuid;

Level(
{this.assetPath,
this.displayIcon,
this.displayName,
this.fullRender,
this.streamedVideo,
this.swatch,
this.uuid});

Level.fromJson(Map<String, dynamic> json) {
assetPath = json['assetPath'];
displayIcon = json['displayIcon'];
displayName = json['displayName'];
fullRender = json['fullRender'];
streamedVideo = json['streamedVideo'];
swatch = json['swatch'];
uuid = json['uuid'];
}
}
14 changes: 14 additions & 0 deletions lib/services/firestore_service.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:valstore/models/firebase_skin.dart';

class FireStoreService {
final FirebaseFirestore _db = FirebaseFirestore.instance;

Future<FirebaseSkin?> getSkin(String uuid) async {
var docRef = _db.collection("skins").doc(uuid);

var snapshot = await docRef.get();

return FirebaseSkin.fromJson(snapshot.data()!);
}
}
Loading

0 comments on commit c816a41

Please sign in to comment.