Add Active Sessions Page
This commit is contained in:
parent
40f609d160
commit
ded4c84d51
3 changed files with 108 additions and 0 deletions
lib
|
@ -44,6 +44,15 @@ Future<dynamic> loginPost({email, password}) async {
|
|||
return req.statusCode;
|
||||
}
|
||||
|
||||
Future<dynamic> getSessions() async {
|
||||
String tempKey =
|
||||
'rTugfHPB7Cd4I1OmsbFCHuJvBSjA2C48WOcMghviohNlNj8IZqazvtwJrdGFHDwp';
|
||||
var req = await Dio()
|
||||
.post(host + '/sessions', queryParameters: {'key': tempKey});
|
||||
var res = req.data;
|
||||
return res;
|
||||
}
|
||||
|
||||
Future<dynamic> getTransactions() async {
|
||||
String tempKey =
|
||||
'rTugfHPB7Cd4I1OmsbFCHuJvBSjA2C48WOcMghviohNlNj8IZqazvtwJrdGFHDwp';
|
||||
|
|
50
lib/components/session_box.dart
Normal file
50
lib/components/session_box.dart
Normal file
|
@ -0,0 +1,50 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class SessionBox extends StatelessWidget {
|
||||
const SessionBox({Key? key, required this.icon, required this.ip, required this.userAgent}) : super(key: key);
|
||||
|
||||
final Icon icon;
|
||||
final String ip;
|
||||
final String userAgent;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.all(8.0),
|
||||
child: Card(
|
||||
color: const Color(0xff212226),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: (){},
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.all(10.0),
|
||||
child: icon
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
flex: 3,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.all(10.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(ip, style: const TextStyle(color: Colors.white, fontSize: 20.0, fontWeight: FontWeight.w600), textAlign: TextAlign.start,),
|
||||
const SizedBox(height: 10.0,),
|
||||
Text(userAgent, style: const TextStyle(color: Colors.white, fontSize: 15.0, fontWeight: FontWeight.w300),)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
49
lib/screens/sessions.dart
Normal file
49
lib/screens/sessions.dart
Normal file
|
@ -0,0 +1,49 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:nekoya_flutter/api/api.dart';
|
||||
import 'package:nekoya_flutter/components/session_box.dart';
|
||||
|
||||
class Sessions extends StatefulWidget {
|
||||
const Sessions({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<Sessions> createState() => _SessionsState();
|
||||
}
|
||||
|
||||
class _SessionsState extends State<Sessions> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xff1b1c1e),
|
||||
appBar: AppBar(
|
||||
title: const Text('Active Sessions'),
|
||||
centerTitle: true,
|
||||
backgroundColor: const Color(0xff212226),
|
||||
),
|
||||
body: FutureBuilder<dynamic>(
|
||||
future: getSessions(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
var data = snapshot.data;
|
||||
return ListView.builder(
|
||||
itemCount: data!.length,
|
||||
itemBuilder: (context, index) {
|
||||
return SessionBox(
|
||||
icon: const Icon(Icons.key, color: Colors.white, size: 50,),
|
||||
ip: data[index]['ip'].split(', ')[0],
|
||||
userAgent: data[index]['user_agent'],
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Color(0xff8B0000),
|
||||
),
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue