Start writing the web app
All checks were successful
ci/woodpecker/push/build Pipeline was successful
All checks were successful
ci/woodpecker/push/build Pipeline was successful
Signed-off-by: Nikolai Rodionov <allanger@posteo.com>
This commit was merged in pull request #5.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:softplayer_dart_proto/src/accounts/v1/accounts_v1.pbgrpc.dart';
|
||||
import 'package:softplayer_web/features/authorization/data/public_accounts_grpc_repository.dart';
|
||||
|
||||
class DashboardState {
|
||||
final bool authorized;
|
||||
|
||||
const DashboardState({this.authorized = false});
|
||||
DashboardState copyWith({bool? authorized}) {
|
||||
return DashboardState(authorized: authorized ?? this.authorized);
|
||||
}
|
||||
}
|
||||
|
||||
final dashboardControllerProvider =
|
||||
AsyncNotifierProvider<DashboardController, DashboardState>(
|
||||
DashboardController.new,
|
||||
);
|
||||
|
||||
class DashboardController extends AsyncNotifier<DashboardState> {
|
||||
static const _storage = FlutterSecureStorage();
|
||||
@override
|
||||
Future<DashboardState> build() async {
|
||||
final accessToken = await _storage.read(key: "x-access-token");
|
||||
if (accessToken == null || accessToken.isEmpty) {
|
||||
return const DashboardState(authorized: false);
|
||||
}
|
||||
return const DashboardState(authorized: true);
|
||||
}
|
||||
}
|
||||
31
lib/features/dashboard/presentation/dashboard_page.dart
Normal file
31
lib/features/dashboard/presentation/dashboard_page.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:softplayer_web/features/test/application/test_controller.dart';
|
||||
|
||||
class DashboardPage extends ConsumerStatefulWidget {
|
||||
const DashboardPage({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<DashboardPage> createState() => _DashboardPage();
|
||||
}
|
||||
|
||||
class _DashboardPage extends ConsumerState<DashboardPage> {
|
||||
bool debug = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ctrl = ref.read(pingControllerProvider.notifier);
|
||||
log("test");
|
||||
return Container(
|
||||
color: Colors.black87,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
ctrl.ping();
|
||||
},
|
||||
child: Text("pong"),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user