-
-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
132 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:lichess_mobile/src/model/relation/relation_repository_providers.dart'; | ||
import 'package:lichess_mobile/src/widgets/list.dart'; | ||
|
||
import 'package:lichess_mobile/src/widgets/platform.dart'; | ||
import 'package:lichess_mobile/src/utils/l10n_context.dart'; | ||
import 'package:lichess_mobile/src/styles/lichess_colors.dart'; | ||
import 'package:lichess_mobile/src/widgets/shimmer.dart'; | ||
|
||
class FollowingScreen extends StatelessWidget { | ||
const FollowingScreen({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return PlatformWidget(androidBuilder: _buildAndroid, iosBuilder: _buildIos); | ||
} | ||
|
||
Widget _buildIos(BuildContext context) { | ||
return CupertinoPageScaffold( | ||
navigationBar: CupertinoNavigationBar( | ||
previousPageTitle: context.l10n.friends, | ||
middle: const Text("Following"), | ||
), | ||
child: const _Body(), | ||
); | ||
} | ||
|
||
Widget _buildAndroid(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text(context.l10n.leaderboard), | ||
), | ||
body: const _Body(), | ||
); | ||
} | ||
} | ||
|
||
class _Body extends ConsumerWidget { | ||
const _Body(); | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final following = ref.watch(followingProvider); | ||
|
||
return following.when( | ||
data: (data) { | ||
if (data.isEmpty) { | ||
const Center( | ||
child: Text("You are not following any user"), | ||
); | ||
} | ||
return SafeArea( | ||
child: ListSection( | ||
children: [ | ||
for (final user in data) | ||
PlatformListTile( | ||
onTap: () => {}, | ||
title: Padding( | ||
padding: const EdgeInsets.only(right: 5.0), | ||
child: Row( | ||
children: [ | ||
if (user.title != null) ...[ | ||
Text( | ||
user.title!, | ||
style: const TextStyle( | ||
color: LichessColors.brag, | ||
fontWeight: FontWeight.bold, | ||
), | ||
), | ||
const SizedBox(width: 5), | ||
], | ||
Flexible( | ||
child: Text( | ||
user.username, | ||
overflow: TextOverflow.ellipsis, | ||
), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
], | ||
), | ||
); | ||
}, | ||
error: (error, stackTrace) { | ||
debugPrint( | ||
'SEVERE: [FollowingScreen] could not following users; $error\n$stackTrace', | ||
); | ||
return const Text('Could not load following users.'); | ||
}, | ||
loading: () => Shimmer( | ||
child: ShimmerLoading( | ||
isLoading: true, | ||
child: ListSection.loading( | ||
itemsNumber: 10, | ||
header: true, | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters