Skip to content

Commit

Permalink
feat: displaying user physical ID
Browse files Browse the repository at this point in the history
  • Loading branch information
IamMuuo committed May 24, 2024
1 parent 2917102 commit 3e0333f
Show file tree
Hide file tree
Showing 7 changed files with 193 additions and 3 deletions.
Binary file added assets/logos/du-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions lib/exports/barrel.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export 'package:flutter/material.dart';
export 'package:academia/widgets/widgets.dart';
export 'package:academia/constants/common.dart';
export 'package:ionicons/ionicons.dart';
export 'package:academia/widgets/academia_app_bar.dart';
Expand Down
32 changes: 32 additions & 0 deletions lib/pages/membership_pages.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'package:academia/exports/barrel.dart';
import 'package:get/get.dart';

class MembershipPage extends StatefulWidget {
const MembershipPage({super.key});

@override
State<MembershipPage> createState() => _MembershipPageState();
}

class _MembershipPageState extends State<MembershipPage> {
final UserController userController = Get.find<UserController>();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Your Memberships"),
),
body: SafeArea(
minimum: const EdgeInsets.symmetric(horizontal: 8),
child: Center(
child: Hero(
tag: "membership",
child: SchoolIDCard(
user: userController.user.value!,
),
),
),
),
);
}
}
16 changes: 13 additions & 3 deletions lib/pages/profile_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:academia/exports/barrel.dart';
import 'package:academia/pages/membership_pages.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';

Expand Down Expand Up @@ -99,9 +100,18 @@ class ProfilePage extends StatelessWidget {
],
),
const SizedBox(height: 16),
TextButton(
onPressed: () {},
child: const Text("Preview school ID"),
Hero(
tag: "membership",
child: TextButton(
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const MembershipPage(),
),
);
},
child: const Text("Preview school ID"),
),
),
const SizedBox(height: 16),
],
Expand Down
145 changes: 145 additions & 0 deletions lib/widgets/school_id_card_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import 'package:academia/exports/barrel.dart';
import 'package:academia/models/user/user.dart';
import 'package:google_fonts/google_fonts.dart';

class SchoolIDCard extends StatelessWidget {
const SchoolIDCard({super.key, required this.user});
final User user;

@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: Theme.of(context).colorScheme.shadow,
),
),
padding: const EdgeInsets.all(16),
constraints: BoxConstraints(
maxWidth: MediaQuery.of(context).size.width,
maxHeight: 250,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Row(
children: [
Image.asset(
"assets/logos/du-logo.png",
width: 80,
),
const Spacer(),
Text(
"STUDENT",
style: Theme.of(context).textTheme.titleLarge?.copyWith(
color: Colors.red,
fontWeight: FontWeight.w700,
),
)
],
),
const SizedBox(height: 4),
Text(
user.name!.toUpperCase(),
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontFamily: GoogleFonts.jetBrainsMono().fontFamily,
),
textAlign: TextAlign.left,
),
const SizedBox(height: 8),
Row(
children: [
Flexible(
flex: 1,
child: ClipRRect(
borderRadius: BorderRadius.circular(200),
child: CircleAvatar(
radius: 60,
child: Image.memory(
Uint8List.fromList(
base64Decode(user.profile!
.replaceFirst("data:image/gif;base64,", "")),
),
fit: BoxFit.contain,
),
),
),
),
const SizedBox(width: 12),
Flexible(
flex: 2,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Row(
children: [
Text(
"ID/ Passport: ",
style:
Theme.of(context).textTheme.bodySmall?.copyWith(
fontWeight: FontWeight.bold,
fontFamily:
GoogleFonts.jetBrainsMono().fontFamily,
),
),
Text(
user.idno!,
style:
Theme.of(context).textTheme.bodySmall?.copyWith(
fontFamily:
GoogleFonts.jetBrainsMono().fontFamily,
),
),
],
),
const SizedBox(height: 8),
Row(
children: [
Text(
"Admission: ",
style:
Theme.of(context).textTheme.bodySmall?.copyWith(
fontWeight: FontWeight.bold,
fontFamily:
GoogleFonts.jetBrainsMono().fontFamily,
),
),
Text(
user.regno!,
style:
Theme.of(context).textTheme.bodySmall?.copyWith(
fontFamily:
GoogleFonts.jetBrainsMono().fontFamily,
),
),
],
),
const SizedBox(height: 8),
Text(
user.regno!,
textAlign: TextAlign.left,
style: Theme.of(context).textTheme.displayLarge?.copyWith(
fontWeight: FontWeight.bold,
fontFamily:
GoogleFonts.libreBarcode128().fontFamily,
),
),
],
),
)
],
),
const Spacer(),
Text(
"*Note that this is a duplicate, data provided here is as is",
style: Theme.of(context)
.textTheme
.bodySmall
?.copyWith(color: Colors.red),
),
],
),
);
}
}
1 change: 1 addition & 0 deletions lib/widgets/widgets.dart
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export 'package:academia/widgets/stat.dart';
export 'school_id_card_widget.dart';
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ flutter:
assets:
- assets/icons/
- assets/images/
- assets/logos/
- shorebird.yaml
# - images/a_dot_ham.jpeg

Expand Down

0 comments on commit 3e0333f

Please sign in to comment.