177 lines
5.6 KiB
Dart
177 lines
5.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:regroup/Common/CommonGlassmorphism.dart';
|
|
import 'package:regroup/Main_Screens/ProfileTab/view_model/profileGetmethod.dart';
|
|
|
|
import 'package:regroup/Utils/Common/CommonAppbar.dart';
|
|
import 'package:regroup/Utils/Common/sized_box.dart';
|
|
import 'package:regroup/Utils/texts.dart';
|
|
|
|
class AccountSession extends StatefulWidget {
|
|
const AccountSession({super.key});
|
|
|
|
@override
|
|
State<AccountSession> createState() => _AccountSessionState();
|
|
}
|
|
|
|
class _AccountSessionState extends State<AccountSession> {
|
|
List sessionData = [
|
|
"london, United Kingdom",
|
|
"Elm street london, United Kingdom",
|
|
"Elm street london, United Kingdom"
|
|
];
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
// key: _scaffoldKey1,
|
|
resizeToAvoidBottomInset: false,
|
|
backgroundColor: const Color(0xFF222935),
|
|
extendBody: true,
|
|
appBar: const CommonAppbar(
|
|
titleTxt: "Account sessions",
|
|
),
|
|
body: FutureBuilder(
|
|
future: Profilegetmethod().getAccountSessions(),
|
|
builder: (ctx, snapshot) {
|
|
if (snapshot.data == null) {
|
|
return const Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Center(
|
|
child: CircularProgressIndicator(
|
|
color: Color(0xFFC18948),
|
|
),
|
|
)
|
|
],
|
|
);
|
|
}
|
|
if (snapshot.connectionState == ConnectionState.done) {
|
|
if (snapshot.hasError) {
|
|
return Center(
|
|
child: Text(
|
|
'${snapshot.error} occured',
|
|
style: TextStyle(fontSize: 18.spMin),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
return accountsessionobj!.data!.isEmpty
|
|
? _buildNoDataBody(context)
|
|
: _buildBody(context);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildNoDataBody(context) {
|
|
return Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
"No Data Found",
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 16.sp,
|
|
fontWeight: FontWeight.w600),
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildBody(context) {
|
|
return Stack(children: [
|
|
Container(
|
|
decoration: const BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage("assets/images/png/Ellipse 1496.png"),
|
|
fit: BoxFit.fill)),
|
|
),
|
|
Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
|
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
|
sizedBoxHeight(25.h),
|
|
text18w400white("Last login sessions"),
|
|
sizedBoxHeight(16.h),
|
|
ListView.builder(
|
|
shrinkWrap: true,
|
|
physics: const ScrollPhysics(),
|
|
itemCount: accountsessionobj!.data!.length,
|
|
itemBuilder: (context, index) {
|
|
final city = accountsessionobj!.data![index].city;
|
|
final state = accountsessionobj!.data![index].state;
|
|
final country = accountsessionobj!.data![index].country;
|
|
|
|
// Combine city, state, and country
|
|
final locationTitle = '$city, $state, $country';
|
|
return sessionCard(
|
|
title: locationTitle,
|
|
devicename: accountsessionobj!.data![index].deviceName!,
|
|
ipaddress: accountsessionobj!.data![index].ipAddress!);
|
|
},
|
|
)
|
|
]),
|
|
)
|
|
]);
|
|
}
|
|
|
|
Widget sessionCard(
|
|
{required String title,
|
|
required String devicename,
|
|
required String ipaddress}) {
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 15),
|
|
child: commonGlassUI(
|
|
width: double.infinity,
|
|
height: 90.h,
|
|
borderRadius: BorderRadius.circular( 10.r),
|
|
customWidget: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
children: [
|
|
commonGlassUI(
|
|
width: 25.w,
|
|
height: 25.h,
|
|
opacity1: 0.24,
|
|
opacity2: 0.24,
|
|
borderRadius: BorderRadius.circular( 100),
|
|
customWidget: Center(
|
|
child: Image.asset(
|
|
"assets/images/png/Group 58645.png",
|
|
height: 13.h,
|
|
width: 9.w,
|
|
),
|
|
),
|
|
borderwidth: 1),
|
|
sizedBoxWidth(10.w),
|
|
text16400white(title),
|
|
],
|
|
),
|
|
sizedBoxHeight(16.h),
|
|
Row(
|
|
children: [
|
|
text14400whiteblur(devicename),
|
|
sizedBoxWidth(6.w),
|
|
Icon(
|
|
Icons.circle,
|
|
size: 7.sp,
|
|
color: Colors.white,
|
|
),
|
|
sizedBoxWidth(6.w),
|
|
text144005DFD63(ipaddress.toString())
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
borderwidth: 1),
|
|
);
|
|
}
|
|
}
|