Skip to content

Commit

Permalink
Merge pull request #24 from Koenigseder/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Koenigseder authored Oct 12, 2023
2 parents 0b5d3f3 + 6279d89 commit 2f44c5a
Show file tree
Hide file tree
Showing 29 changed files with 2,051 additions and 547 deletions.
11 changes: 8 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion flutter.compileSdkVersion
compileSdkVersion 33
ndkVersion flutter.ndkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8

coreLibraryDesugaringEnabled true
}

kotlinOptions {
Expand All @@ -53,10 +55,12 @@ android {
applicationId "me.koenigseder.lisp"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
minSdkVersion 30
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName

multiDexEnabled true
}

signingConfigs {
Expand All @@ -81,4 +85,5 @@ flutter {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
}
30 changes: 20 additions & 10 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,34 +1,44 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="me.koenigseder.lisp">
<application
android:label="Lisp"

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<application
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
android:icon="@mipmap/ic_launcher"
android:label="Lisp">
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />

<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />

<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="task_updated" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/notification_icon" />
</application>
</manifest>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>

<monochrome android:drawable="@mipmap/ic_launcher_monochrome_foreground"/>
</adaptive-icon>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<foreground android:drawable="@mipmap/ic_launcher_monochrome_foreground"/>
</adaptive-icon>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath 'com.android.tools.build:gradle:7.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.google.gms:google-services:4.3.13"
classpath "com.google.gms:google-services:4.3.15"
}
}

Expand All @@ -27,6 +27,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
Binary file added assets/images/logo_mono.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 16 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:lisp/screens/auth.dart';
import 'package:lisp/screens/verify_email.dart';
import 'package:lisp/services/push_service.dart';
import 'package:lisp/utils/snackbar.dart';

Future main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();

// Notifications
await firebaseMessagingRequestNotificationPermission();

await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(
alert: true,
badge: true,
sound: true,
);

FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler);
FirebaseMessaging.onMessage
.listen((RemoteMessage msg) => firebaseMessagingForegroundHandler(msg));

runApp(const MyApp());
}

Expand Down
70 changes: 67 additions & 3 deletions lib/mainpage.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:lisp/screens/home.dart';
import 'package:lisp/screens/settings.dart';
import 'package:lisp/services/firestore_service.dart';
import 'package:lisp/services/push_service.dart';
import 'package:lisp/services/storage_service.dart';

class MainPage extends StatefulWidget {
const MainPage({Key? key}) : super(key: key);
Expand All @@ -12,6 +17,10 @@ class MainPage extends StatefulWidget {
class _MainPageState extends State<MainPage> {
int _selectedIndex = 0;

final StorageService _storageService = StorageService();

String profilePicturePath = "";

static const List<Widget> _widgetOptions = [
HomePage(),
SettingsPage(),
Expand All @@ -23,21 +32,76 @@ class _MainPageState extends State<MainPage> {
});
}

void updateProfilePicturePath() {
_storageService
.getProfilePictureURL(FirebaseAuth.instance.currentUser!.uid)
.then((value) {
setState(() {
profilePicturePath = value;
});
});
}

Future<void> getTaskIds(Stream<dynamic> user) async {
await for (final props in user) {
List<String> tasks = [];
for (final task in props.tasks) {
tasks.add(task["task_id"]);
}

subscribeToTopics(tasks);
}
}

@override
void initState() {
super.initState();

updateProfilePicturePath();

final firestore = FirestoreService();
getTaskIds(firestore.readUser());
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: _widgetOptions.elementAt(_selectedIndex),
),
bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
items: <BottomNavigationBarItem>[
const BottomNavigationBarItem(
icon: Icon(Icons.home),
label: "Home",
backgroundColor: Colors.purple,
),
BottomNavigationBarItem(
icon: Icon(Icons.settings),
icon: CircleAvatar(
radius: 12.0,
backgroundColor: Colors.transparent,
child: ClipOval(
child: Image.network(
profilePicturePath,
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) {
return Center(
child: SvgPicture.string(
_storageService.getAvatarString(
FirebaseAuth.instance.currentUser!.uid,
),
),
);
},
loadingBuilder: (context, child, loadingProgress) {
if (loadingProgress == null) return child;
return const Center(
child: CircularProgressIndicator(),
);
},
),
),
),
label: "Settings",
backgroundColor: Colors.green,
),
Expand Down
10 changes: 5 additions & 5 deletions lib/models/firestore_user.dart
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
class FirestoreUser {
FirestoreUser({required this.name, this.tasks});
FirestoreUser({required this.name, this.tasks, this.fcm});

String name;
List<dynamic>? tasks;
List<dynamic>? fcm;

Map<String, dynamic> toJson() {
return {
"name": name,
"tasks": tasks,
};
return {"name": name, "tasks": tasks, "fcm": fcm};
}

static FirestoreUser fromJson(Map<String, dynamic>? json) {
if (json == null) {
return FirestoreUser(
name: "Default user",
tasks: [],
fcm: [],
);
}

return FirestoreUser(
name: json["name"],
tasks: json["tasks"],
fcm: json["fcm"],
);
}
}
Loading

0 comments on commit 2f44c5a

Please sign in to comment.