Skip to content

Commit 62522df

Browse files
committed
[Launcher] feat: implement kick member and transfer leader functionality for parties
1 parent 308a00c commit 62522df

6 files changed

Lines changed: 124 additions & 79 deletions

File tree

Launcher/lib/core/config/colors.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const kDefaultActiveColor = Color(0xfffab20a);
99
const kInactiveColor = Color.fromRGBO(191, 191, 191, 1);
1010
const kWhiteColor = Color.fromRGBO(210, 220, 225, 1);
1111
const kWhiteColor1 = Color.fromRGBO(145, 145, 145, 1);
12-
const kButtonBorder = Color.fromRGBO(120, 130, 135, 1);
12+
const kButtonBorder = Color(0xFF5C5C5C);
1313
const kGrayColor = Color(0xFF6D767B);
1414
const kWhiteBackgroundColor = Color.fromRGBO(67, 73, 76, 1);
1515
const decoColor = Color.fromRGBO(56, 65, 69, 1);

Launcher/lib/features/maxima/dialogs/maxima_friends_dialog.dart

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import 'package:kyber_launcher/features/maxima/widgets/maxima_avatar.dart';
1111
import 'package:kyber_launcher/features/session/providers/session_cubit.dart';
1212
import 'package:kyber_launcher/gen/fonts.gen.dart';
1313
import 'package:kyber_launcher/gen/rust/api/maxima.dart';
14-
import 'package:kyber_launcher/shared/ui/buttons/normal_button.dart';
1514
import 'package:kyber_launcher/shared/ui/ui.dart';
1615
import 'package:super_sliver_list/super_sliver_list.dart';
1716

@@ -347,15 +346,41 @@ class _MemberTile extends StatelessWidget {
347346
right: 0,
348347
top: 0,
349348
bottom: 0,
350-
child: Row(
351-
children: [
352-
KOutlinedButton(
353-
child: Icon(mt.Icons.close_sharp, size: 25),
354-
onPressed: () {
355-
// TODO: Implement kick from party
356-
},
357-
),
358-
],
349+
child: SizedBox(
350+
height: 35,
351+
child: Row(
352+
spacing: 15,
353+
children: [
354+
SizedBox(
355+
child: KOutlinedButton(
356+
child: const Text('MAKE LEADER'),
357+
onPressed: () {
358+
try {
359+
context.read<SessionCubit>().transferLeader(id);
360+
} on GrpcError catch (e) {
361+
NotificationService.error(
362+
message:
363+
'Failed to transfer leadership: ${e.message}',
364+
);
365+
}
366+
},
367+
),
368+
),
369+
KOutlinedButton(
370+
padding: const .symmetric(horizontal: 20, vertical: 5),
371+
child: const Icon(mt.Icons.close_sharp, size: 22),
372+
onPressed: () {
373+
try {
374+
context.read<SessionCubit>().kickFromParty(id);
375+
} on GrpcError catch (e) {
376+
NotificationService.error(
377+
message: 'Failed to kick member: ${e.message}',
378+
);
379+
}
380+
},
381+
),
382+
],
383+
),
359384
),
360385
),
361386
],

Launcher/lib/features/navigation_bar/widgets/social_bar.dart

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
44
import 'package:kyber_launcher/core/core.dart';
55
import 'package:kyber_launcher/features/download_manager/models/download_state.dart';
66
import 'package:kyber_launcher/features/download_manager/providers/download_manager_cubit.dart';
7+
import 'package:kyber_launcher/features/maxima/dialogs/maxima_friends_dialog.dart';
78
import 'package:kyber_launcher/features/maxima/providers/maxima_cubit.dart';
89
import 'package:kyber_launcher/features/maxima/providers/maxima_rtm_cubit.dart';
910
import 'package:kyber_launcher/features/maxima/widgets/maxima_avatar.dart';
@@ -123,33 +124,46 @@ class _UserBar extends StatelessWidget {
123124
return const SizedBox.shrink();
124125
}
125126

126-
return Container(
127-
margin: const .symmetric(vertical: 7),
128-
decoration: BoxDecoration(
129-
border: const .fromBorderSide(.new(color: decoColor, width: 1)),
130-
borderRadius: const .all(.circular(6)),
131-
color: Colors.black.withOpacity(0.5),
127+
return ButtonBuilder(
128+
onClick: () => showKyberDialog(
129+
context: context,
130+
builder: (_) => const MaximaFriendsDialog(),
132131
),
133-
padding: const .symmetric(horizontal: 3, vertical: 3),
134-
child: Row(
135-
spacing: 10,
136-
children: [
137-
MaximaAvatar(
138-
pd: currentUser.pd,
139-
height: 24,
140-
width: 24,
132+
builder: (context, hovered) {
133+
final color = switch (hovered) {
134+
true => kActiveColor,
135+
false => decoColor,
136+
};
137+
138+
return Container(
139+
margin: const .symmetric(vertical: 7),
140+
decoration: BoxDecoration(
141+
border: .fromBorderSide(.new(color: color, width: 1)),
142+
borderRadius: const .all(.circular(6)),
143+
color: Colors.black.withOpacity(0.5),
141144
),
142-
Text(
143-
currentUser.displayName,
144-
style: const TextStyle(
145-
fontSize: 16,
146-
fontFamily: FontFamily.battlefrontUI,
147-
height: 1.1,
148-
),
145+
padding: const .symmetric(horizontal: 3, vertical: 3),
146+
child: Row(
147+
spacing: 10,
148+
children: [
149+
MaximaAvatar(
150+
pd: currentUser.pd,
151+
height: 24,
152+
width: 24,
153+
),
154+
Text(
155+
currentUser.displayName,
156+
style: const TextStyle(
157+
fontSize: 16,
158+
fontFamily: FontFamily.battlefrontUI,
159+
height: 1.1,
160+
),
161+
),
162+
const SizedBox.shrink(),
163+
],
149164
),
150-
const SizedBox.shrink(),
151-
],
152-
),
165+
);
166+
},
153167
);
154168
}
155169
}

Launcher/lib/features/session/providers/session_cubit.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ class SessionCubit extends Cubit<SessionState> {
6363
return _service.partyServiceClient.invitePlayer(.new(userId: userId));
6464
}
6565

66+
Future<void> kickFromParty(String userId) {
67+
return _service.partyServiceClient.kickMember(.new(userId: userId));
68+
}
69+
70+
Future<void> transferLeader(String userId) {
71+
return _service.partyServiceClient.transferLeader(.new(userId: userId));
72+
}
73+
6674
Future<void> acceptInvite(Int64 partyId) async {
6775
await _service.partyServiceClient.acceptInvite(.new(partyId: partyId));
6876

Launcher/lib/shared/ui/buttons/button.dart

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -260,22 +260,23 @@ class _KyberButtonState extends State<KyberButton>
260260
class CurveClipper extends CustomClipper<Path> {
261261
@override
262262
Path getClip(Size size) {
263-
final path_0 = Path();
264-
path_0.moveTo(5, 0);
265-
path_0.lineTo(size.width - 12.5, 0);
266-
path_0.lineTo(size.width, 12.5);
267-
path_0.lineTo(size.width, size.height - 5);
268-
path_0.quadraticBezierTo(
269-
size.width,
270-
size.height,
271-
size.width - 5,
272-
size.height,
273-
);
274-
path_0.lineTo(5, size.height);
275-
path_0.quadraticBezierTo(0, size.height, 0, size.height - 5);
276-
path_0.lineTo(0, 5);
277-
path_0.quadraticBezierTo(0, 0, 5, 0);
278-
path_0.close();
263+
final path_0 = Path()
264+
..moveTo(7, 0)
265+
..lineTo(size.width - 12.5, 0)
266+
..lineTo(size.width, 12.5)
267+
..lineTo(size.width, size.height - 7)
268+
..quadraticBezierTo(
269+
size.width,
270+
size.height,
271+
size.width - 7,
272+
size.height,
273+
)
274+
..lineTo(7, size.height)
275+
..quadraticBezierTo(0, size.height, 0, size.height - 7)
276+
..lineTo(0, 7)
277+
..quadraticBezierTo(0, 0, 7, 0)
278+
..close();
279+
279280
return path_0;
280281
}
281282

@@ -299,27 +300,27 @@ class CurvePainter extends CustomPainter {
299300

300301
@override
301302
void paint(Canvas canvas, Size size) {
302-
final path_0 = Path();
303-
path_0.moveTo(5, 0);
304-
path_0.lineTo(size.width - 12.5, 0);
305-
path_0.lineTo(size.width, 12.5);
306-
path_0.lineTo(size.width, size.height - 5);
307-
path_0.quadraticBezierTo(
308-
size.width,
309-
size.height,
310-
size.width - 5,
311-
size.height,
312-
);
313-
path_0.lineTo(5, size.height);
314-
path_0.quadraticBezierTo(0, size.height, 0, size.height - 5);
315-
path_0.lineTo(0, 5);
316-
path_0.quadraticBezierTo(0, 0, 5, 0);
317-
path_0.close();
303+
final path_0 = Path()
304+
..moveTo(7, 0)
305+
..lineTo(size.width - 12.5, 0)
306+
..lineTo(size.width, 12.5)
307+
..lineTo(size.width, size.height - 7)
308+
..quadraticBezierTo(
309+
size.width,
310+
size.height,
311+
size.width - 7,
312+
size.height,
313+
)
314+
..lineTo(7, size.height)
315+
..quadraticBezierTo(0, size.height, 0, size.height - 7)
316+
..lineTo(0, 7)
317+
..quadraticBezierTo(0, 0, 7, 0)
318+
..close();
318319

319-
final path_1 = Path();
320-
path_1.moveTo(33, 0);
321-
path_1.lineTo(33, size.height);
322-
path_1.close();
320+
final path_1 = Path()
321+
..moveTo(33, 0)
322+
..lineTo(33, size.height)
323+
..close();
323324

324325
late Color color;
325326
if (!highlighted) {
@@ -330,20 +331,19 @@ class CurvePainter extends CustomPainter {
330331
begin: kButtonBorder,
331332
end: kActiveColor,
332333
).evaluate(animation)!;
333-
//color = kButtonBorder;
334334
}
335335
} else {
336336
color = kActiveColor;
337337
}
338338

339339
final paintStroke0 = Paint()
340340
..color = color
341-
..style = PaintingStyle.stroke
341+
..style = .stroke
342342
..strokeWidth = highlighted
343343
? Tween<double>(begin: 3, end: 5).evaluate(animation)
344344
: 4
345-
..strokeCap = StrokeCap.round
346-
..strokeJoin = StrokeJoin.round;
345+
..strokeCap = .round
346+
..strokeJoin = .round;
347347

348348
canvas.drawPath(path_0, paintStroke0);
349349
if (hasIcon) {

Launcher/lib/shared/ui/buttons/normal_button.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ class KOutlinedButton extends StatelessWidget {
203203
};
204204

205205
return Container(
206+
padding: buttonPadding,
206207
decoration: BoxDecoration(
207208
color: const Color(0xFFD9D9D9).withOpacity(.1),
208209
border: .all(
@@ -221,10 +222,7 @@ class KOutlinedButton extends StatelessWidget {
221222
fontFamily: FontFamily.battlefrontUI,
222223
fontWeight: .w700,
223224
),
224-
child: Padding(
225-
padding: buttonPadding,
226-
child: child,
227-
),
225+
child: child,
228226
),
229227
),
230228
);

0 commit comments

Comments
 (0)