diff --git a/android/google-services.json b/android/google-services.json
deleted file mode 100644
index 14e8c7b..0000000
--- a/android/google-services.json
+++ /dev/null
@@ -1,39 +0,0 @@
-{
- "project_info": {
- "project_number": "659822066072",
- "project_id": "smartsheep-hydrogen",
- "storage_bucket": "smartsheep-hydrogen.appspot.com"
- },
- "client": [
- {
- "client_info": {
- "mobilesdk_app_id": "1:659822066072:android:39e699282c97a7cfc013ed",
- "android_client_info": {
- "package_name": "dev.solsynth.solaragent"
- }
- },
- "oauth_client": [
- {
- "client_id": "659822066072-dde0aqiocn28bc1gk9p5k8oaqe1jpi0l.apps.googleusercontent.com",
- "client_type": 3
- }
- ],
- "api_key": [
- {
- "current_key": "AIzaSyBLPaAK4CVW9umXIdUoGOGHO42jKnwZkKo"
- }
- ],
- "services": {
- "appinvite_service": {
- "other_platform_oauth_client": [
- {
- "client_id": "659822066072-dde0aqiocn28bc1gk9p5k8oaqe1jpi0l.apps.googleusercontent.com",
- "client_type": 3
- }
- ]
- }
- }
- }
- ],
- "configuration_version": "1"
-}
\ No newline at end of file
diff --git a/ios/GoogleService-Info.plist b/ios/GoogleService-Info.plist
deleted file mode 100644
index 287c574..0000000
--- a/ios/GoogleService-Info.plist
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
- API_KEY
- AIzaSyBQB4u2KKe1P5jMG_zWGiUFtpcjQKhG3jY
- GCM_SENDER_ID
- 659822066072
- PLIST_VERSION
- 1
- BUNDLE_ID
- dev.solsynth.solaragent
- PROJECT_ID
- smartsheep-hydrogen
- STORAGE_BUCKET
- smartsheep-hydrogen.appspot.com
- IS_ADS_ENABLED
-
- IS_ANALYTICS_ENABLED
-
- IS_APPINVITE_ENABLED
-
- IS_GCM_ENABLED
-
- IS_SIGNIN_ENABLED
-
- GOOGLE_APP_ID
- 1:659822066072:ios:90dff099ef47fc8fc013ed
-
-
\ No newline at end of file
diff --git a/ios/firebase_app_id_file.json b/ios/firebase_app_id_file.json
deleted file mode 100644
index e8cc171..0000000
--- a/ios/firebase_app_id_file.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "file_generated_by": "FlutterFire CLI",
- "purpose": "FirebaseAppID & ProjectID for this Firebase app in this directory",
- "GOOGLE_APP_ID": "1:659822066072:ios:90dff099ef47fc8fc013ed",
- "FIREBASE_PROJECT_ID": "smartsheep-hydrogen",
- "GCM_SENDER_ID": "659822066072"
-}
\ No newline at end of file
diff --git a/lib/router.dart b/lib/router.dart
index d539b68..c416d69 100644
--- a/lib/router.dart
+++ b/lib/router.dart
@@ -1,7 +1,9 @@
import 'package:go_router/go_router.dart';
+import 'package:solaragent/models/feed.dart';
import 'package:solaragent/screens/account.dart';
import 'package:solaragent/screens/explore.dart';
import 'package:solaragent/screens/notifications.dart';
+import 'package:solaragent/screens/publish/comment_editor.dart';
import 'package:solaragent/screens/publish/moment_editor.dart';
final router = GoRouter(
@@ -18,10 +20,14 @@ final router = GoRouter(
path: '/account',
builder: (context, state) => const AccountScreen(),
),
-
GoRoute(
path: '/post/moments',
builder: (context, state) => const MomentEditorScreen(),
),
+ GoRoute(
+ path: '/post/comments',
+ builder: (context, state) =>
+ CommentEditorScreen(parent: state.extra as Feed),
+ ),
],
);
diff --git a/lib/screens/publish/comment_editor.dart b/lib/screens/publish/comment_editor.dart
new file mode 100644
index 0000000..1641784
--- /dev/null
+++ b/lib/screens/publish/comment_editor.dart
@@ -0,0 +1,167 @@
+import 'dart:convert';
+
+import 'package:flutter/cupertino.dart';
+import 'package:flutter/material.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+import 'package:solaragent/auth.dart';
+import 'package:solaragent/models/feed.dart';
+import 'package:solaragent/router.dart';
+import 'package:url_launcher/url_launcher.dart';
+
+class CommentEditorScreen extends StatefulWidget {
+ final Feed parent;
+
+ const CommentEditorScreen({super.key, required this.parent});
+
+ @override
+ State createState() => _CommentEditorScreenState();
+}
+
+class _CommentEditorScreenState extends State {
+ final contentController = TextEditingController();
+
+ bool isSubmitting = false;
+
+ bool showRecommendationBanner = true;
+
+ Future postComment() async {
+ if (!await authClient.isAuthorized()) return;
+
+ var dataset = "${widget.parent.modelType}s";
+ var alias = widget.parent.alias;
+
+ var uri = Uri.parse(
+ "https://co.solsynth.dev/api/p/$dataset/$alias/comments",
+ );
+
+ setState(() => isSubmitting = true);
+ var res = await authClient.client!.post(
+ uri,
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: jsonEncode({
+ 'content': contentController.value.text,
+ }),
+ );
+ if (res.statusCode != 200) {
+ var message = utf8.decode(res.bodyBytes);
+ ScaffoldMessenger.of(context).showSnackBar(
+ SnackBar(content: Text("Something went wrong... $message")),
+ );
+ } else {
+ if (router.canPop()) {
+ router.pop();
+ }
+ }
+ setState(() => isSubmitting = false);
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppBar(
+ title: const Text("Leave a comment"),
+ actions: [
+ TextButton(
+ onPressed: !isSubmitting ? postComment : null,
+ child: const Text('POST'),
+ ),
+ ],
+ ),
+ body: Column(
+ children: [
+ // Loading indicator
+ isSubmitting ? const LinearProgressIndicator() : Container(),
+ // Userinfo
+ FutureBuilder(
+ future: authClient.getProfiles(),
+ builder: (context, snapshot) {
+ if (snapshot.hasData) {
+ var userinfo = snapshot.data;
+ return Container(
+ color: Colors.grey[50],
+ margin: const EdgeInsets.only(bottom: 12),
+ child: ListTile(
+ title: Text(userinfo["nick"]),
+ subtitle: const Text("You will post this post as"),
+ leading: CircleAvatar(
+ backgroundImage: NetworkImage(userinfo["picture"]),
+ ),
+ ),
+ );
+ } else {
+ return Container();
+ }
+ }),
+ // Editor
+ Expanded(
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
+ child: TextField(
+ maxLines: null,
+ autofocus: true,
+ autocorrect: true,
+ keyboardType: TextInputType.multiline,
+ controller: contentController,
+ decoration: const InputDecoration.collapsed(
+ hintText: "What do you want to say?"),
+ ),
+ ),
+ ),
+ // Recommend website banner
+ showRecommendationBanner
+ ? FutureBuilder(
+ future: SharedPreferences.getInstance(),
+ builder: (context, snapshot) {
+ if (snapshot.hasData &&
+ snapshot.data?.getBool(
+ "editor.hide_website_recommendation") ==
+ null) {
+ snapshot.data
+ ?.remove("editor.hide_website_recommendation");
+ return MaterialBanner(
+ padding: const EdgeInsets.all(20),
+ content: const Text(
+ 'SolarAgent still in early stage development. Some features isn\'t available. We recommend use our website, also optimized for moblie!',
+ ),
+ leading: const Icon(Icons.construction),
+ backgroundColor: const Color(0xFFE0E0E0),
+ actions: [
+ TextButton(
+ child: const Text('OPEN'),
+ onPressed: () async {
+ await launchUrl(
+ Uri.parse("https://co.solsynth.dev"));
+ },
+ ),
+ TextButton(
+ child: const Text('DISMISS'),
+ onPressed: () async {
+ await snapshot.data?.setBool(
+ "editor.hide_website_recommendation",
+ true,
+ );
+ setState(() {
+ showRecommendationBanner = false;
+ });
+ },
+ ),
+ ],
+ );
+ } else {
+ return Container();
+ }
+ })
+ : Container(),
+ ],
+ ),
+ );
+ }
+
+ @override
+ void dispose() {
+ contentController.dispose();
+ super.dispose();
+ }
+}
diff --git a/lib/widgets/posts/comments.dart b/lib/widgets/posts/comments.dart
index 76ad099..7c18f21 100644
--- a/lib/widgets/posts/comments.dart
+++ b/lib/widgets/posts/comments.dart
@@ -3,8 +3,10 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart';
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
+import 'package:solaragent/auth.dart';
import 'package:solaragent/models/feed.dart';
import 'package:solaragent/models/pagination.dart';
+import 'package:solaragent/router.dart';
import 'package:solaragent/widgets/feed.dart';
class CommentListWidget extends StatefulWidget {
@@ -69,11 +71,36 @@ class _CommentListWidgetState extends State {
children: [
Container(
padding: const EdgeInsets.only(left: 10, right: 10, top: 20),
- child: ListTile(
- title: Text(
- 'Comments',
- style: Theme.of(context).textTheme.headlineSmall,
- ),
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Padding(
+ padding: const EdgeInsets.symmetric(
+ horizontal: 8.0,
+ vertical: 12.0,
+ ),
+ child: Text(
+ 'Comments',
+ style: Theme.of(context).textTheme.headlineSmall,
+ ),
+ ),
+ FutureBuilder(
+ future: authClient.isAuthorized(),
+ builder: (context, snapshot) {
+ if (snapshot.hasData && snapshot.data == true) {
+ return TextButton.icon(
+ icon: const Icon(Icons.edit),
+ label: const Text("LEAVE COMMENT"),
+ onPressed: () {
+ router.push("/post/comments", extra: widget.parent);
+ },
+ );
+ } else {
+ return Container();
+ }
+ },
+ ),
+ ],
),
),
Expanded(