Skip to content

Commit

Permalink
Updated SplashScreen and added Add Friend via ID
Browse files Browse the repository at this point in the history
  • Loading branch information
F4zination committed Jul 6, 2024
1 parent 870a382 commit b0ffc24
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 22 deletions.
Binary file modified duo_client/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion duo_client/lib/screens/dashboard_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
onPressed: () {
showDialog(
context: context,
builder: (context) => const AddFriendDialog(),
builder: (context) => AddFriendDialog(),
);
},
),
Expand Down
17 changes: 14 additions & 3 deletions duo_client/lib/screens/splash_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,20 @@ class _SplasScreenState<T> extends State<SplashScreen> {
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SpinKitFadingCube(
color: Theme.of(context).colorScheme.primary,
size: 50.0,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
'assets/Logo.png',
width: 100.0,
height: 100.0,
),
const SizedBox(height: 40.0),
SpinKitFadingCube(
color: Theme.of(context).colorScheme.primary,
size: 50.0,
),
],
),
),
);
Expand Down
86 changes: 69 additions & 17 deletions duo_client/lib/widgets/add_friend_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import 'package:duo_client/screens/qr_scanner_screen.dart';
import 'package:duo_client/utils/constants.dart';
import 'package:duo_client/widgets/qr_join_dialog.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:share_plus/share_plus.dart';

class AddFriendDialog extends ConsumerWidget {
const AddFriendDialog({super.key});
AddFriendDialog({super.key});
final TextEditingController _controller = TextEditingController();

@override
Widget build(BuildContext context, WidgetRef ref) {
Expand All @@ -19,7 +21,7 @@ class AddFriendDialog extends ConsumerWidget {
insetPadding: const EdgeInsets.all(20),
child: SizedBox(
width: 400,
height: MediaQuery.of(context).size.height * 0.4,
height: MediaQuery.of(context).size.height * 0.45,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expand All @@ -32,21 +34,24 @@ class AddFriendDialog extends ConsumerWidget {
fontWeight: FontWeight.bold,
color: Colors.white70)),
const SizedBox(height: Constants.defaultPadding),
const SizedBox(height: Constants.defaultPadding),
const Text(
'Join via id:',
style: TextStyle(color: Colors.white, fontSize: 16),
),
const SizedBox(height: Constants.defaultPadding),
SizedBox(
width: double.infinity,
child: Text(
ref.read(storageProvider).userId,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white.withOpacity(0.8),
fontSize: 18,
fontWeight: FontWeight.bold),
child: InkWell(
onLongPress: () => Clipboard.setData(
ClipboardData(text: ref.read(storageProvider).userId)),
child: Text(
ref.read(storageProvider).userId,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white.withOpacity(0.8),
fontSize: 15,
fontWeight: FontWeight.bold),
),
),
),
const SizedBox(height: Constants.defaultPadding),
Expand Down Expand Up @@ -74,6 +79,7 @@ class AddFriendDialog extends ConsumerWidget {
final String? friendId = await Navigator.of(context)
.pushNamed(QrCodeScanner.route) as String?;
if (friendId != null) {
print('Friend id: $friendId');
await ref.read(apiProvider).sendFriendRequest(
await ref.read(apiProvider).getToken(),
ref.read(storageProvider).username,
Expand All @@ -92,17 +98,63 @@ class AddFriendDialog extends ConsumerWidget {
await Share.share(
'Add me as a friend with my id in DUO: *${ref.read(storageProvider).userId}*');
},
)
),
],
),
),
const SizedBox(height: Constants.defaultPadding),
ElevatedButton(
onPressed: () {
Navigator.of(context).pop();
},
child:
const Text('Cancel', style: TextStyle(color: Colors.white)),
const Padding(
padding: EdgeInsets.all(8.0),
child: Divider(),
),
const SizedBox(height: Constants.defaultPadding),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 2 * Constants.defaultPadding),
child: TextField(
controller: _controller,
decoration: const InputDecoration(
hintText: 'Enter friend id',
hintStyle: TextStyle(color: Colors.white54),
border: OutlineInputBorder(
borderSide: BorderSide(color: Colors.white54),
),
),
style: const TextStyle(color: Colors.white),
onSubmitted: (value) async {
ref.read(apiProvider).sendFriendRequest(
await ref.read(apiProvider).getToken(),
ref.read(storageProvider).username,
value);
},
),
),
const SizedBox(height: Constants.defaultPadding),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ElevatedButton(
onPressed: () {
Navigator.of(context).pop();
},
child: const Text('Cancel',
style: TextStyle(color: Colors.white)),
),
ElevatedButton(
onPressed: () async {
ref
.read(apiProvider)
.sendFriendRequest(
await ref.read(apiProvider).getToken(),
ref.read(storageProvider).username,
_controller.text)
.then((value) {
Navigator.of(context).pop();
});
},
child: const Text('Add',
style: TextStyle(color: Colors.white)))
],
),
const SizedBox(height: Constants.defaultPadding),
],
Expand Down
3 changes: 2 additions & 1 deletion duo_client/lib/widgets/friend_request_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ class FriendRequestTile extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
return DuoContainer(
height: 56,
child: Row(
children: [
Helpers.getCircleAvatar(text: friendRequest.requesterName),
const SizedBox(width: Constants.defaultPadding / 2),
Text(
'Freundschaftsanfrage von ${friendRequest.requesterName}',
'Freundschaftsanfrage von \n${friendRequest.requesterName}',
style: const TextStyle(
color: Colors.white70, fontWeight: FontWeight.bold),
),
Expand Down
1 change: 1 addition & 0 deletions duo_client/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ flutter:
- res/images/
- res/icons/
- assets/game/
- assets/
- assets/game/duo_cards/
- .env
# - images/a_dot_ham.jpeg
Expand Down

0 comments on commit b0ffc24

Please sign in to comment.