💄 Optimized UX

This commit is contained in:
LittleSheep 2024-02-10 20:08:25 +08:00
parent 30a237741a
commit cb7256af23
6 changed files with 85 additions and 67 deletions

View File

@ -94,12 +94,16 @@ PODS:
- nanopb/encode (= 2.30909.1) - nanopb/encode (= 2.30909.1)
- nanopb/decode (2.30909.1) - nanopb/decode (2.30909.1)
- nanopb/encode (2.30909.1) - nanopb/encode (2.30909.1)
- package_info_plus (0.4.5):
- Flutter
- path_provider_foundation (0.0.1): - path_provider_foundation (0.0.1):
- Flutter - Flutter
- FlutterMacOS - FlutterMacOS
- PromisesObjC (2.3.1) - PromisesObjC (2.3.1)
- PromisesSwift (2.3.1): - PromisesSwift (2.3.1):
- PromisesObjC (= 2.3.1) - PromisesObjC (= 2.3.1)
- url_launcher_ios (0.0.1):
- Flutter
- webview_flutter_wkwebview (0.0.1): - webview_flutter_wkwebview (0.0.1):
- Flutter - Flutter
@ -110,7 +114,9 @@ DEPENDENCIES:
- Flutter (from `Flutter`) - Flutter (from `Flutter`)
- flutter_appauth (from `.symlinks/plugins/flutter_appauth/ios`) - flutter_appauth (from `.symlinks/plugins/flutter_appauth/ios`)
- flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`) - flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
- webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`) - webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`)
SPEC REPOS: SPEC REPOS:
@ -143,8 +149,12 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_appauth/ios" :path: ".symlinks/plugins/flutter_appauth/ios"
flutter_secure_storage: flutter_secure_storage:
:path: ".symlinks/plugins/flutter_secure_storage/ios" :path: ".symlinks/plugins/flutter_secure_storage/ios"
package_info_plus:
:path: ".symlinks/plugins/package_info_plus/ios"
path_provider_foundation: path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin" :path: ".symlinks/plugins/path_provider_foundation/darwin"
url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios"
webview_flutter_wkwebview: webview_flutter_wkwebview:
:path: ".symlinks/plugins/webview_flutter_wkwebview/ios" :path: ".symlinks/plugins/webview_flutter_wkwebview/ios"
@ -167,9 +177,11 @@ SPEC CHECKSUMS:
GoogleDataTransport: 57c22343ab29bc686febbf7cbb13bad167c2d8fe GoogleDataTransport: 57c22343ab29bc686febbf7cbb13bad167c2d8fe
GoogleUtilities: 0759d1a57ebb953965c2dfe0ba4c82e95ccc2e34 GoogleUtilities: 0759d1a57ebb953965c2dfe0ba4c82e95ccc2e34
nanopb: d4d75c12cd1316f4a64e3c6963f879ecd4b5e0d5 nanopb: d4d75c12cd1316f4a64e3c6963f879ecd4b5e0d5
package_info_plus: 115f4ad11e0698c8c1c5d8a689390df880f47e85
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4 PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4
PromisesSwift: 28dca69a9c40779916ac2d6985a0192a5cb4a265 PromisesSwift: 28dca69a9c40779916ac2d6985a0192a5cb4a265
url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812
webview_flutter_wkwebview: be0f0d33777f1bfd0c9fdcb594786704dbf65f36 webview_flutter_wkwebview: be0f0d33777f1bfd0c9fdcb594786704dbf65f36
PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796 PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796

View File

@ -74,9 +74,11 @@ class AuthGuard {
..addAll(authorizationUrl.queryParameters)); ..addAll(authorizationUrl.queryParameters));
// Use WebView to get authorization url // Use WebView to get authorization url
var responseUrl = await Navigator.of(context).push(MaterialPageRoute( var responseUrl = await Navigator.of(context, rootNavigator: true).push(
builder: (context) => AuthorizationScreen(authorizationUrl), MaterialPageRoute(
)); builder: (context) => AuthorizationScreen(authorizationUrl),
),
);
var responseUri = Uri.parse(responseUrl); var responseUri = Uri.parse(responseUrl);
return await grant return await grant

View File

@ -1,11 +1,11 @@
import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart'; import 'package:goatagent/screens/account.dart';
import 'package:goatagent/screens/dashboard.dart';
import 'package:goatagent/screens/notifications.dart';
class AgentNavigation extends StatefulWidget { class AgentNavigation extends StatefulWidget {
const AgentNavigation({super.key, required this.router}); const AgentNavigation({super.key});
final GoRouter router;
static const items = [ static const items = [
NavigationDestination( NavigationDestination(
@ -22,20 +22,17 @@ class AgentNavigation extends StatefulWidget {
) )
]; ];
static const destinations = ["/", "/notifications", "/account"];
@override @override
State<AgentNavigation> createState() => _AgentNavigationState(); State<AgentNavigation> createState() => _AgentNavigationState();
} }
class _AgentNavigationState extends State<AgentNavigation> { class _AgentNavigationState extends State<AgentNavigation> {
int _selected = 0; int _view = 0;
Future<void> initMessage(BuildContext context) async { Future<void> initMessage(BuildContext context) async {
void navigate() { void navigate() {
widget.router.replace("/notifications");
setState(() { setState(() {
_selected = 1; _view = 1;
}); });
} }
@ -59,16 +56,33 @@ class _AgentNavigationState extends State<AgentNavigation> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return NavigationBar( return Scaffold(
selectedIndex: _selected, body: Stack(
labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected, children: [
destinations: AgentNavigation.items, Offstage(
onDestinationSelected: (index) { offstage: _view != 0,
widget.router.replace(AgentNavigation.destinations[index]); child: const DashboardScreen(),
setState(() { ),
_selected = index; Offstage(
}); offstage: _view != 1,
}, child: const NotificationScreen(),
),
Offstage(
offstage: _view != 2,
child: const AccountScreen(),
)
],
),
bottomNavigationBar: NavigationBar(
selectedIndex: _view,
labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected,
destinations: AgentNavigation.items,
onDestinationSelected: (index) {
setState(() {
_view = index;
});
},
),
); );
} }
} }

View File

@ -20,54 +20,35 @@ void main() async {
await AuthGuard().pickClient(); await AuthGuard().pickClient();
runApp(GoatAgent()); runApp(const GoatAgent());
} }
class GoatAgent extends StatelessWidget { class GoatAgent extends StatelessWidget {
final _router = GoRouter( const GoatAgent({super.key});
navigatorKey: GlobalKey<NavigatorState>(),
routes: [
GoRoute(
path: '/',
builder: (context, state) => const DashboardScreen(),
),
GoRoute(
path: '/notifications',
builder: (context, state) => const NotificationScreen(),
),
GoRoute(
path: '/account',
builder: (context, state) => const AccountScreen(),
),
GoRoute(
path: '/about',
builder: (context, state) => const AboutScreen(),
),
],
);
GoatAgent({super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp.router( return MaterialApp(
routerConfig: _router,
title: 'GoatAgent', title: 'GoatAgent',
theme: ThemeData( theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.indigo), brightness: Brightness.light,
colorScheme: ColorScheme.fromSwatch(
primarySwatch: Colors.indigo,
accentColor: Colors.indigoAccent,
backgroundColor: Colors.white,
brightness: Brightness.light),
useMaterial3: true, useMaterial3: true,
), ),
builder: (BuildContext context, Widget? child) { darkTheme: ThemeData(
return Overlay(initialEntries: [ brightness: Brightness.dark,
OverlayEntry( colorScheme: ColorScheme.fromSwatch(
builder: (context) => Scaffold( primarySwatch: Colors.indigo,
body: child, accentColor: Colors.indigoAccent,
// bottomNavigationBar: const AgentBottomNavigation() backgroundColor: Colors.black12,
bottomNavigationBar: AgentNavigation(router: _router), brightness: Brightness.dark),
), useMaterial3: true,
) ),
]); home: const AgentNavigation(),
},
); );
} }
} }

View File

@ -1,14 +1,22 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart'; import 'package:webview_flutter/webview_flutter.dart';
class AuthorizationScreen extends StatelessWidget { class ApplicationScreen extends StatelessWidget {
final Uri link; final Uri link;
final String title;
const AuthorizationScreen(this.link, {super.key}); const ApplicationScreen({super.key, required this.link, required this.title});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: PreferredSize(
preferredSize: const Size.fromHeight(32.0),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 18),
child: AppBar(),
)
),
body: SafeArea( body: SafeArea(
child: WebViewWidget( child: WebViewWidget(
controller: WebViewController() controller: WebViewController()

View File

@ -1,10 +1,9 @@
import 'dart:convert'; import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:goatagent/screens/application.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'application.dart';
class DashboardScreen extends StatefulWidget { class DashboardScreen extends StatefulWidget {
const DashboardScreen({super.key}); const DashboardScreen({super.key});
@ -46,9 +45,11 @@ class _DashboardScreenState extends State<DashboardScreen> {
return Card( return Card(
child: InkWell( child: InkWell(
onTap: () async { onTap: () async {
await Navigator.of(context).push(MaterialPageRoute( var link = element["link"];
builder: (context) => AuthorizationScreen( Navigator.of(context, rootNavigator: true).push(MaterialPageRoute(
Uri.parse(element["link"]), builder: (context) => ApplicationScreen(
link: Uri.parse(link),
title: element["name"],
), ),
)); ));
}, },