♻️ Refactored and joined the Solar Network
This commit is contained in:
@ -16,9 +16,9 @@ class AboutScreen extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text('GoatAgent',
|
||||
Text('SolarAgent',
|
||||
style: Theme.of(context).textTheme.headlineMedium),
|
||||
Text('Goatworks Official Mobile Helper',
|
||||
Text('Solarworks Official Mobile Helper',
|
||||
style: Theme.of(context).textTheme.bodyLarge),
|
||||
const SizedBox(height: 20),
|
||||
FutureBuilder(
|
||||
@ -37,7 +37,7 @@ class AboutScreen extends StatelessWidget {
|
||||
const SizedBox(height: 10),
|
||||
MaterialButton(
|
||||
onPressed: () async {
|
||||
await launchUrl(Uri.parse('https://smartsheep.studio'));
|
||||
await launchUrl(Uri.parse('https://solsynth.dev'));
|
||||
},
|
||||
child: const Text('Official Website'),
|
||||
),
|
||||
|
@ -1,8 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:goatagent/auth.dart';
|
||||
import 'package:goatagent/screens/about.dart';
|
||||
import 'package:goatagent/widgets/name_card.dart';
|
||||
import 'package:solaragent/auth.dart';
|
||||
import 'package:solaragent/screens/about.dart';
|
||||
import 'package:solaragent/widgets/name_card.dart';
|
||||
|
||||
class AccountScreen extends StatefulWidget {
|
||||
const AccountScreen({super.key});
|
||||
@ -17,7 +17,7 @@ class _AccountScreenState extends State<AccountScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
AuthGuard().isAuthorized().then((value) {
|
||||
authClient.isAuthorized().then((value) {
|
||||
setState(() {
|
||||
isAuthorized = value;
|
||||
});
|
||||
@ -35,8 +35,8 @@ class _AccountScreenState extends State<AccountScreen> {
|
||||
padding: const EdgeInsets.only(top: 20),
|
||||
child: NameCard(
|
||||
onLogin: () async {
|
||||
await AuthGuard().login(context);
|
||||
var authorized = await AuthGuard().isAuthorized();
|
||||
await authClient.login(context);
|
||||
var authorized = await authClient.isAuthorized();
|
||||
setState(() {
|
||||
isAuthorized = authorized;
|
||||
});
|
||||
@ -49,44 +49,43 @@ class _AccountScreenState extends State<AccountScreen> {
|
||||
spacing: 5,
|
||||
children: [
|
||||
FutureBuilder(
|
||||
future: AuthGuard().isAuthorized(),
|
||||
builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
|
||||
if (snapshot.hasData && snapshot.data == true) {
|
||||
return Card(
|
||||
elevation: 0,
|
||||
child: InkWell(
|
||||
splashColor: Colors.indigo.withAlpha(30),
|
||||
onTap: () async {
|
||||
AuthGuard().logout();
|
||||
var authorized = await AuthGuard().isAuthorized();
|
||||
setState(() {
|
||||
isAuthorized = authorized;
|
||||
});
|
||||
},
|
||||
child: const ListTile(
|
||||
leading: Icon(Icons.logout),
|
||||
title: Text('Logout'),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
future: authClient.isAuthorized(),
|
||||
builder:
|
||||
(BuildContext context, AsyncSnapshot<bool> snapshot) {
|
||||
return (snapshot.hasData && snapshot.data == true)
|
||||
? InkWell(
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(40)),
|
||||
splashColor: Colors.indigo.withAlpha(30),
|
||||
onTap: () async {
|
||||
authClient.logout();
|
||||
var authorized =
|
||||
await authClient.isAuthorized();
|
||||
setState(() {
|
||||
isAuthorized = authorized;
|
||||
});
|
||||
},
|
||||
child: const ListTile(
|
||||
leading: Icon(Icons.logout),
|
||||
title: Text('Logout'),
|
||||
),
|
||||
)
|
||||
: Container();
|
||||
},
|
||||
),
|
||||
Card(
|
||||
elevation: 0,
|
||||
child: InkWell(
|
||||
splashColor: Colors.indigo.withAlpha(30),
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
builder: (context) => const AboutScreen(),
|
||||
));
|
||||
},
|
||||
child: const ListTile(
|
||||
leading: Icon(Icons.info_outline),
|
||||
title: Text('About'),
|
||||
),
|
||||
InkWell(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(40)),
|
||||
splashColor: Colors.indigo.withAlpha(30),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const AboutScreen(),
|
||||
));
|
||||
},
|
||||
child: const ListTile(
|
||||
leading: Icon(Icons.info_outline),
|
||||
title: Text('About'),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
@ -11,7 +11,7 @@ class AuthorizationScreen extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Connect with Goatpass'),
|
||||
title: const Text('Sign in'),
|
||||
),
|
||||
body: Stack(children: [
|
||||
WebViewWidget(
|
||||
@ -20,10 +20,10 @@ class AuthorizationScreen extends StatelessWidget {
|
||||
..setBackgroundColor(Colors.white)
|
||||
..setNavigationDelegate(NavigationDelegate(
|
||||
onNavigationRequest: (NavigationRequest request) {
|
||||
if (request.url.startsWith('goatagent://auth')) {
|
||||
if (request.url.startsWith('solaragent://auth')) {
|
||||
Navigator.of(context).pop(request.url);
|
||||
return NavigationDecision.prevent;
|
||||
} else if (request.url.startsWith("https://id.smartsheep.studio/auth/register")) {
|
||||
} else if (request.url.startsWith("https://solsynth.dev/auth/sign-up")) {
|
||||
launchUrl(Uri.parse(request.url));
|
||||
return NavigationDecision.prevent;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:goatagent/screens/application.dart';
|
||||
import 'package:solaragent/screens/application.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class DashboardScreen extends StatefulWidget {
|
||||
@ -14,7 +14,7 @@ class DashboardScreen extends StatefulWidget {
|
||||
class _DashboardScreenState extends State<DashboardScreen> {
|
||||
final client = http.Client();
|
||||
final directoryEndpoint =
|
||||
Uri.parse('https://id.smartsheep.studio/.well-known');
|
||||
Uri.parse('https://id.solsynth.dev/.well-known');
|
||||
|
||||
List<dynamic> directory = List.empty();
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:goatagent/auth.dart';
|
||||
import 'package:solaragent/auth.dart';
|
||||
|
||||
class NotificationScreen extends StatefulWidget {
|
||||
const NotificationScreen({super.key});
|
||||
@ -12,7 +12,7 @@ class NotificationScreen extends StatefulWidget {
|
||||
|
||||
class _NotificationScreenState extends State<NotificationScreen> {
|
||||
final notificationEndpoint = Uri.parse(
|
||||
'https://id.smartsheep.studio/api/notifications?skip=0&take=20');
|
||||
'https://id.solsynth.dev/api/notifications?skip=0&take=25');
|
||||
|
||||
List<dynamic> notifications = List.empty();
|
||||
|
||||
@ -23,9 +23,9 @@ class _NotificationScreenState extends State<NotificationScreen> {
|
||||
}
|
||||
|
||||
Future<void> _pullNotifications() async {
|
||||
if (await AuthGuard().isAuthorized()) {
|
||||
await AuthGuard().pullProfiles();
|
||||
var profiles = await AuthGuard().readProfiles();
|
||||
if (await authClient.isAuthorized()) {
|
||||
await authClient.pullProfiles();
|
||||
var profiles = await authClient.readProfiles();
|
||||
setState(() {
|
||||
notifications = profiles['notifications'];
|
||||
});
|
||||
@ -33,11 +33,11 @@ class _NotificationScreenState extends State<NotificationScreen> {
|
||||
}
|
||||
|
||||
Future<void> _markAsRead(element) async {
|
||||
if (AuthGuard().client != null) {
|
||||
if (authClient.client != null) {
|
||||
var id = element['id'];
|
||||
var uri =
|
||||
Uri.parse('https://id.smartsheep.studio/api/notifications/$id/read');
|
||||
await AuthGuard().client!.put(uri);
|
||||
Uri.parse('https://id.solsynth.dev/api/notifications/$id/read');
|
||||
await authClient.client!.put(uri);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user