Skip to content

Commit

Permalink
Merge pull request #7 from JothishKamal/dev
Browse files Browse the repository at this point in the history
feat: admin screen backend integration + fixes
  • Loading branch information
souvik03-136 authored Dec 29, 2024
2 parents 5cefd4d + ccb3cee commit b93751f
Show file tree
Hide file tree
Showing 32 changed files with 2,403 additions and 706 deletions.
7 changes: 7 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="collabify" android:host="auth"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
Expand Down
33 changes: 33 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,39 @@ allprojects {
rootProject.buildDir = "../build"
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"

afterEvaluate {
// check if android block is available

if (it.hasProperty('android')) {
if (it.android.namespace == null) {
def manifest = new XmlSlurper().parse(file(it.android.sourceSets.main.manifest.srcFile))
def packageName = manifest.@package.text()
println("Setting ${packageName} as android namespace")
android.namespace = packageName
}

def javaVersion = JavaVersion.VERSION_17
android {
def androidApiVersion = 34
compileSdkVersion androidApiVersion
defaultConfig {
targetSdkVersion androidApiVersion
}
compileOptions {
sourceCompatibility javaVersion
targetCompatibility javaVersion
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = javaVersion.toString()
}
}

}
}

}
}
subprojects {
project.evaluationDependsOn(":app")
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
4 changes: 2 additions & 2 deletions android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
id "com.android.application" version "8.6.1" apply false
id "org.jetbrains.kotlin.android" version "1.9.0" apply false
}

include ":app"
19 changes: 19 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,39 @@ PODS:
- Flutter (1.0.0)
- image_picker_ios (0.0.1):
- Flutter
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
- uni_links (0.0.1):
- Flutter
- url_launcher_ios (0.0.1):
- Flutter

DEPENDENCIES:
- Flutter (from `Flutter`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- uni_links (from `.symlinks/plugins/uni_links/ios`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)

EXTERNAL SOURCES:
Flutter:
:path: Flutter
image_picker_ios:
:path: ".symlinks/plugins/image_picker_ios/ios"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
uni_links:
:path: ".symlinks/plugins/uni_links/ios"
url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios"

SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
uni_links: d97da20c7701486ba192624d99bffaaffcfc298a
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe

PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796

Expand Down
12 changes: 12 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,17 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.example.spotifycollab</string>
<key>CFBundleURLSchemes</key>
<array>
<string>collabify</string>
</array>
</dict>
</array>

</dict>
</plist>
12 changes: 7 additions & 5 deletions lib/app/app.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import 'package:flutter/material.dart';

import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:spotify_collab_app/app/router/router.dart';
import 'package:spotify_collab_app/app/theme/theme.dart';

class CollabifyApp extends StatelessWidget {
class CollabifyApp extends ConsumerWidget {
const CollabifyApp({super.key});

@override
Widget build(BuildContext context) {
Widget build(BuildContext context, WidgetRef ref) {
final goRouter = ref.read(routerProvider);

return MaterialApp.router(
title: 'Kalculate',
title: 'Collabify',
theme: darkTheme,
// themeMode: ThemeMode.dark,
debugShowCheckedModeBanner: false,
routerConfig: router,
routerConfig: goRouter,
);
}
}
Expand Down
109 changes: 60 additions & 49 deletions lib/app/router/router.dart
Original file line number Diff line number Diff line change
@@ -1,59 +1,70 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:spotify_collab_app/view/screens/admin_screen.dart';
import 'package:spotify_collab_app/view/screens/create_screen.dart';
import 'package:spotify_collab_app/view/screens/join_screen.dart';
import 'package:spotify_collab_app/view/screens/landing_screen.dart';
import 'package:spotify_collab_app/view/screens/login_screen.dart';
import 'package:spotify_collab_app/view/screens/signup_screen.dart';
import 'package:spotify_collab_app/view/screens/home_screen.dart';
import 'package:spotify_collab_app/view/screens/connect_screen.dart';
import 'package:spotify_collab_app/view/screens/splash_screen.dart';

final router = GoRouter(
initialLocation: '/',
routes: <GoRoute>[
GoRoute(
path: '/',
pageBuilder: (context, state) => const MaterialPage(
child: LandingScreen(),
),
routes: [
GoRoute(
path: 'login',
pageBuilder: (context, state) =>
const MaterialPage(child: LoginScreen()),
),
GoRoute(
path: 'signup',
pageBuilder: (context, state) =>
const MaterialPage(child: SignupScreen()),
),
GoRoute(
path: 'connect',
pageBuilder: (context, state) =>
const MaterialPage(child: ConnectScreen()),
),
GoRoute(
path: 'home',
pageBuilder: (context, state) =>
const MaterialPage(child: HomeScreen()),
),
GoRoute(
path: 'create',
pageBuilder: (context, state) =>
const MaterialPage(child: CreateScreen()),
),
GoRoute(
path: 'join',
pageBuilder: (context, state) =>
const MaterialPage(child: JoinScreen()),
),
GoRoute(
path: 'admin',
pageBuilder: (context, state) =>
const MaterialPage(child: AdminScreen()),
),
],
),
],
);
final routerProvider = Provider<GoRouter>((ref) {
return GoRouter(
errorBuilder: (context, state) {
return const HomeScreen();
},
initialLocation: '/',
routes: <GoRoute>[
GoRoute(
path: '/',
pageBuilder: (context, state) => const MaterialPage(
child: SplashScreen(),
),
),
GoRoute(
path: '/connect',
pageBuilder: (context, state) => const MaterialPage(
child: ConnectScreen(),
),
),
GoRoute(
path: '/home',
pageBuilder: (context, state) => const MaterialPage(
child: HomeScreen(),
),
),
GoRoute(
path: '/login',
pageBuilder: (context, state) => const MaterialPage(
child: LoginScreen(),
),
),
GoRoute(
path: '/signup',
pageBuilder: (context, state) => const MaterialPage(
child: SignupScreen(),
),
),
GoRoute(
path: '/create',
pageBuilder: (context, state) => const MaterialPage(
child: CreateScreen(),
),
),
GoRoute(
path: '/join',
pageBuilder: (context, state) => const MaterialPage(
child: JoinScreen(),
),
),
GoRoute(
path: '/admin',
pageBuilder: (context, state) => const MaterialPage(
child: AdminScreen(),
),
),
],
);
});
2 changes: 2 additions & 0 deletions lib/constants/constants.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const devUrl =
'https://spotify-collab-backend-jothishkamal.onrender.com';
92 changes: 92 additions & 0 deletions lib/providers/admin_screen_provider.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,100 @@
import 'dart:developer';

import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:spotify_collab_app/utils/api_util.dart';
import 'package:spotify_collab_app/view/models/songs_response.dart';

enum RequestAction { none, acceptAll, rejectAll }

final tabProvider = StateProvider<int>((ref) => 0);

final requestActionProvider =
StateProvider<RequestAction>((ref) => RequestAction.none);

final songsProvider =
StateNotifierProvider<SongsNotifier, SongsResponse>((ref) {
return SongsNotifier();
});

class SongsNotifier extends StateNotifier<SongsResponse> {
SongsNotifier() : super(SongsResponse());

Future<void> fetchSongs(String uuid) async {
var prefs = await SharedPreferences.getInstance();
log(prefs.getString('access_token').toString());
log(uuid);
try {
final response = await apiUtil.get(
'/v1/songs/$uuid',
);

log('Songs fetched');
if (response.statusCode == 200) {
final data = SongsResponse.fromJson(response.data);

state = state.copyWith(
data: data.data,
message: data.message,
statusCode: data.statusCode,
success: data.success,
);
}
} catch (e) {
log(e.toString());
}
}

void clearSongs() {
final emptySongs = SongsResponse();

state = state.copyWith(
data: emptySongs.data,
message: emptySongs.message,
statusCode: emptySongs.statusCode,
success: emptySongs.success,
);
}

Future<bool> acceptSong(String uuid, String uri) async {
try {
final response = await apiUtil.post(
'/v1/songs/accept',
{
'playlist_uuid': uuid,
'song_uri': uri,
},
);

log('Song accepted');
if (response.statusCode == 200) {
fetchSongs(uuid);
return true;
}
} catch (e) {
log(e.toString());
}
return false;
}

Future<bool> rejectSong(String uuid, String uri) async {
try {
final response = await apiUtil.post(
'/v1/songs/reject',
{
'playlist_uuid': uuid,
'song_uri': uri,
},
);

log('Song rejected');
if (response.statusCode == 200) {
fetchSongs(uuid);
return true;
}
} catch (e) {
log(e.toString());
}
return false;
}
}
Loading

0 comments on commit b93751f

Please sign in to comment.