Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
update deps
add timeago
update user search
ui fixes
  • Loading branch information
wheremyfiji committed Jun 2, 2023
1 parent cc7b23e commit 6e75967
Show file tree
Hide file tree
Showing 10 changed files with 264 additions and 142 deletions.
3 changes: 3 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import 'package:path_provider/path_provider.dart' as path_prov;
import 'package:shared_preferences/shared_preferences.dart';
import 'package:window_manager/window_manager.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:timeago/timeago.dart' as timeago;

import 'secret.dart';
import 'src/constants/box_types.dart';
Expand Down Expand Up @@ -59,6 +60,8 @@ void initApp() async {
Intl.defaultLocale = 'ru_RU';
initializeDateFormatting("ru_RU", null);

timeago.setLocaleMessages('ru', timeago.RuMessages());

TargetP.init();

Loggy.initLoggy(
Expand Down
43 changes: 7 additions & 36 deletions lib/src/presentation/pages/anime_details/anime_details_page.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

import 'package:url_launcher/url_launcher_string.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:share_plus/share_plus.dart';
import 'package:shikidev/src/utils/extensions/buildcontext.dart';
import 'package:go_router/go_router.dart';
import 'package:shimmer/shimmer.dart';
import 'package:url_launcher/url_launcher_string.dart';

import 'package:shikidev/src/utils/extensions/buildcontext.dart';

import '../../../constants/config.dart';
import '../../../domain/models/animes.dart';
Expand All @@ -21,11 +23,11 @@ import 'studio_select_page.dart';
import 'widgets/anime_actions.dart';
import 'widgets/anime_chips_widger.dart';
import 'widgets/anime_videos_widget.dart';
import 'widgets/details_fab.dart';
import 'widgets/details_screenshots.dart';
import 'widgets/info_header.dart';
import 'widgets/rates_statuses_widget.dart';
import '../../widgets/title_description.dart';
import 'widgets/user_anime_rate.dart';

const double dividerHeight = 16;

Expand Down Expand Up @@ -67,38 +69,7 @@ class AnimeDetailsPage extends ConsumerWidget {
return Scaffold(
//extendBodyBehindAppBar: true,
floatingActionButton: titleInfo.title.when(
data: (data) {
return FloatingActionButton.extended(
onPressed: () {
showModalBottomSheet<void>(
context: context,
constraints: BoxConstraints(
maxWidth: MediaQuery.of(context).size.width >= 700
? 700
: double.infinity,
),
useRootNavigator: true,
isScrollControlled: true,
enableDrag: false,
useSafeArea: true,
builder: (context) {
return SafeArea(
child: AnimeUserRateBottomSheet(
data: data,
anime: animeData,
),
);
},
);
},
label: data.userRate == null
? const Text('Добавить в список')
: const Text('Изменить'),
icon: data.userRate == null
? const Icon(Icons.add)
: const Icon(Icons.edit),
);
},
data: (data) => AnimeDetailsFAB(data: data, animeData: animeData),
error: (error, stackTrace) => null,
loading: () => null,
),
Expand Down
79 changes: 79 additions & 0 deletions lib/src/presentation/pages/anime_details/widgets/details_fab.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import 'package:flutter/material.dart';

import '../../../../domain/models/anime.dart';
import '../../../../domain/models/animes.dart';
import 'user_anime_rate.dart';

class AnimeDetailsFAB extends StatelessWidget {
final Anime data;
final Animes animeData;

const AnimeDetailsFAB(
{super.key, required this.data, required this.animeData});

String getStatus(String value, int? c) {
String status;

const map = {
'planned': 'В планах',
'watching': 'Смотрю',
'rewatching': 'Пересматриваю',
'completed': 'Просмотрено',
'on_hold': 'Отложено',
'dropped': 'Брошено'
};

status = map[value] ?? '';

return (c != 0 && value == 'watching') ? '$status (Серия $c)' : status;
}

IconData getIcon(String value) {
IconData icon;

const map = {
'planned': Icons.event_available,
'watching': Icons.remove_red_eye,
'rewatching': Icons.refresh,
'completed': Icons.done_all,
'on_hold': Icons.pause,
'dropped': Icons.close
};

icon = map[value] ?? Icons.edit;

return icon;
}

@override
Widget build(BuildContext context) {
return FloatingActionButton.extended(
onPressed: () => showModalBottomSheet<void>(
context: context,
constraints: BoxConstraints(
maxWidth:
MediaQuery.of(context).size.width >= 700 ? 700 : double.infinity,
),
useRootNavigator: true,
isScrollControlled: true,
enableDrag: false,
useSafeArea: true,
builder: (context) {
return SafeArea(
child: AnimeUserRateBottomSheet(
data: data,
anime: animeData,
),
);
},
),
label: data.userRate == null
? const Text('Добавить в список')
: Text(getStatus(
data.userRate!.status ?? 'Изменить', data.userRate!.episodes)),
icon: data.userRate == null
? const Icon(Icons.add)
: Icon(getIcon(data.userRate!.status ?? '')),
);
}
}
84 changes: 42 additions & 42 deletions lib/src/presentation/pages/comments/comments_page.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import 'package:flutter/material.dart';

import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
import 'package:intl/intl.dart';
import 'package:shikidev/src/utils/extensions/string_ext.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:timeago/timeago.dart' as timeago;

//import '../../../domain/models/anime.dart';
import '../../../domain/models/shiki_comment.dart';
import '../../providers/comments_provider.dart';
import '../../widgets/cached_image.dart';
import '../../widgets/cool_chip.dart';

class CommentsPage extends ConsumerWidget {
//final Anime anime;
final int topicId;
const CommentsPage({super.key, required this.topicId});

Expand All @@ -34,7 +33,6 @@ class CommentsPage extends ConsumerWidget {
title: Text('Обсуждение'),
),
SliverPadding(
// padding: const EdgeInsets.all(16.0),
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
sliver: PagedSliverList<int, ShikiComment>(
pagingController: controller.pageController,
Expand All @@ -52,41 +50,41 @@ class CommentsPage extends ConsumerWidget {
),
);

return Scaffold(
body: NestedScrollView(
headerSliverBuilder: (context, innerBoxIsScrolled) {
return [
SliverAppBar.large(
forceElevated: innerBoxIsScrolled,
stretch: true,
title: const Text('Обсуждение'),
),
];
},
body: RefreshIndicator(
onRefresh: () => Future.sync(
() => controller.pageController.refresh(),
),
child: CustomScrollView(
slivers: [
SliverPadding(
padding: const EdgeInsets.all(16.0),
sliver: PagedSliverList<int, ShikiComment>(
pagingController: controller.pageController,
builderDelegate: PagedChildBuilderDelegate<ShikiComment>(
itemBuilder: (context, item, index) {
return CommentWidget(
comment: item,
);
},
),
),
),
],
),
),
),
);
// return Scaffold(
// body: NestedScrollView(
// headerSliverBuilder: (context, innerBoxIsScrolled) {
// return [
// SliverAppBar.large(
// forceElevated: innerBoxIsScrolled,
// stretch: true,
// title: const Text('Обсуждение'),
// ),
// ];
// },
// body: RefreshIndicator(
// onRefresh: () => Future.sync(
// () => controller.pageController.refresh(),
// ),
// child: CustomScrollView(
// slivers: [
// SliverPadding(
// padding: const EdgeInsets.all(16.0),
// sliver: PagedSliverList<int, ShikiComment>(
// pagingController: controller.pageController,
// builderDelegate: PagedChildBuilderDelegate<ShikiComment>(
// itemBuilder: (context, item, index) {
// return CommentWidget(
// comment: item,
// );
// },
// ),
// ),
// ),
// ],
// ),
// ),
// ),
// );
}
}

Expand All @@ -99,8 +97,9 @@ class CommentWidget extends StatelessWidget {
Widget build(BuildContext context) {
final updatedAt =
DateTime.tryParse(comment.updatedAt ?? '')?.toLocal() ?? DateTime(1970);
final date = DateFormat.yMMMMd().format(updatedAt);
final time = DateFormat.Hms().format(updatedAt);

//final date = DateFormat.yMMMMd().format(updatedAt);
//final time = DateFormat.Hms().format(updatedAt);

return Card(
margin: const EdgeInsets.only(bottom: 8),
Expand Down Expand Up @@ -137,7 +136,8 @@ class CommentWidget extends StatelessWidget {
overflow: TextOverflow.ellipsis,
),
Text(
'$date в $time',
//'$date в $time',
timeago.format(updatedAt, locale: 'ru'),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Expand Down
60 changes: 16 additions & 44 deletions lib/src/presentation/pages/manga_detail/manga_detail_page.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:flutter/material.dart';

import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:share_plus/share_plus.dart';
import 'package:shimmer/shimmer.dart';
import 'package:url_launcher/url_launcher_string.dart';

import 'package:shikidev/src/utils/extensions/buildcontext.dart';
import 'package:shikidev/src/utils/extensions/string_ext.dart';

Expand All @@ -19,10 +21,11 @@ import '../../widgets/manga_card.dart';
import '../../widgets/title_description.dart';
import '../anime_details/related_titles.dart';
import '../comments/comments_page.dart';

import 'widgets/manga_chips.dart';
import 'widgets/manga_detail_fab.dart';
import 'widgets/manga_info_header.dart';
import 'widgets/manga_rates_statuses.dart';
import 'widgets/user_rate_widget.dart';

const double dividerHeight = 16;

Expand All @@ -38,38 +41,7 @@ class MangaDetailPage extends ConsumerWidget {
return Scaffold(
//extendBodyBehindAppBar: true,
floatingActionButton: mangaDetails.title.when(
data: (data) {
return FloatingActionButton.extended(
onPressed: () {
showModalBottomSheet<void>(
context: context,
constraints: BoxConstraints(
maxWidth: MediaQuery.of(context).size.width >= 700
? 700
: double.infinity,
),
useRootNavigator: true,
isScrollControlled: true,
enableDrag: false,
useSafeArea: true,
builder: (context) {
return SafeArea(
child: MangaUserRateBottomSheet(
manga: manga,
data: data,
),
);
},
);
},
label: data.userRate == null
? const Text('Добавить в список')
: const Text('Изменить'),
icon: data.userRate == null
? const Icon(Icons.add)
: const Icon(Icons.edit),
);
},
data: (data) => MangaDetailFAB(data: data, manga: manga),
error: (error, stackTrace) => null,
loading: () => null,
),
Expand Down Expand Up @@ -131,17 +103,17 @@ class MangaDetailPage extends ConsumerWidget {
),
),
),
if (data.userRate != null) ...[
SliverPadding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 0),
sliver: SliverToBoxAdapter(
child: UserRateWidget(
manga: manga,
data: data,
),
),
),
],
// if (data.userRate != null) ...[
// SliverPadding(
// padding: const EdgeInsets.fromLTRB(16, 0, 16, 0),
// sliver: SliverToBoxAdapter(
// child: UserRateWidget(
// manga: manga,
// data: data,
// ),
// ),
// ),
// ],
SliverPadding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 8),
sliver: SliverToBoxAdapter(
Expand Down
Loading

0 comments on commit 6e75967

Please sign in to comment.