Skip to content

Commit

Permalink
Merge pull request #6 from guozhigq/alpha
Browse files Browse the repository at this point in the history
Alpha
  • Loading branch information
guozhigq authored Jul 26, 2023
2 parents 9e9422a + c6c1a16 commit e104864
Show file tree
Hide file tree
Showing 27 changed files with 328 additions and 193 deletions.
24 changes: 24 additions & 0 deletions lib/common/widgets/custom_toast.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'package:flutter/material.dart';

class CustomToast extends StatelessWidget {
final String msg;
const CustomToast({Key? key, required this.msg}) : super(key: key);

@override
Widget build(BuildContext context) {
return Container(
margin:
EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom + 20),
padding: const EdgeInsets.symmetric(horizontal: 17, vertical: 10),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primaryContainer.withOpacity(0.8),
borderRadius: BorderRadius.circular(20),
),
child: Text(msg,
style: Theme.of(context)
.textTheme
.labelMedium!
.copyWith(color: Theme.of(context).colorScheme.primary)),
);
}
}
2 changes: 1 addition & 1 deletion lib/common/widgets/stat/danmu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class StatDanMu extends StatelessWidget {
size: 14,
color: color,
),
const SizedBox(width: 3),
const SizedBox(width: 2),
Text(
Utils.numFormat(danmu!),
style: TextStyle(
Expand Down
2 changes: 1 addition & 1 deletion lib/common/widgets/stat/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class StatView extends StatelessWidget {
size: 13,
color: color,
),
const SizedBox(width: 3),
const SizedBox(width: 2),
Text(
Utils.numFormat(view!),
style: TextStyle(
Expand Down
5 changes: 4 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:flutter/material.dart';
import 'package:dynamic_color/dynamic_color.dart';
import 'package:pilipala/common/widgets/custom_toast.dart';
import 'package:pilipala/http/init.dart';
import 'package:pilipala/pages/search/index.dart';
import 'package:pilipala/pages/video/detail/index.dart';
Expand Down Expand Up @@ -61,7 +62,9 @@ class MyApp extends StatelessWidget {
fallbackLocale: const Locale("zh", "CN"),
getPages: Routes.getPages,
home: const MainApp(),
builder: FlutterSmartDialog.init(),
builder: FlutterSmartDialog.init(
toastBuilder: (String msg) => CustomToast(msg: msg),
),
navigatorObservers: [
VideoDetailPage.routeObserver,
SearchPage.routeObserver
Expand Down
2 changes: 2 additions & 0 deletions lib/pages/dynamics/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:pilipala/models/common/dynamics_type.dart';
import 'package:pilipala/models/dynamics/result.dart';
import 'package:pilipala/models/dynamics/up.dart';
import 'package:pilipala/models/live/item.dart';
import 'package:pilipala/utils/feed_back.dart';

class DynamicsController extends GetxController {
int page = 1;
Expand Down Expand Up @@ -78,6 +79,7 @@ class DynamicsController extends GetxController {
}

pushDetail(item, floor, {action = 'all'}) async {
feedBack();
if (action == 'comment') {
Get.toNamed('/dynamicDetail',
arguments: {'item': item, 'floor': floor, 'action': action});
Expand Down
47 changes: 28 additions & 19 deletions lib/pages/dynamics/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:pilipala/common/widgets/http_error.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/models/dynamics/result.dart';
import 'package:pilipala/pages/mine/index.dart';
import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/storage.dart';

import 'controller.dart';
Expand Down Expand Up @@ -143,6 +144,7 @@ class _DynamicsPageState extends State<DynamicsPage>
duration: const Duration(milliseconds: 300),
curve: Curves.easeInOut,
onValueChanged: (v) {
feedBack();
_dynamicsController.onSelectType(v);
},
),
Expand All @@ -155,7 +157,8 @@ class _DynamicsPageState extends State<DynamicsPage>
bottom: 0,
child: IconButton(
padding: EdgeInsets.zero,
onPressed: () => _dynamicsController.resetSearch(),
onPressed: () =>
{feedBack(), _dynamicsController.resetSearch()},
icon: const Icon(Icons.history, size: 21),
),
),
Expand All @@ -167,15 +170,18 @@ class _DynamicsPageState extends State<DynamicsPage>
alignment: Alignment.center,
child: user.get(UserBoxKey.userLogin) ?? false
? GestureDetector(
onTap: () => showModalBottomSheet(
context: context,
builder: (_) => const SizedBox(
height: 450,
child: MinePage(),
),
clipBehavior: Clip.hardEdge,
isScrollControlled: true,
),
onTap: () {
feedBack();
showModalBottomSheet(
context: context,
builder: (_) => const SizedBox(
height: 450,
child: MinePage(),
),
clipBehavior: Clip.hardEdge,
isScrollControlled: true,
);
},
child: NetworkImgLayer(
type: 'avatar',
width: 30,
Expand All @@ -184,15 +190,18 @@ class _DynamicsPageState extends State<DynamicsPage>
),
)
: IconButton(
onPressed: () => showModalBottomSheet(
context: context,
builder: (_) => const SizedBox(
height: 450,
child: MinePage(),
),
clipBehavior: Clip.hardEdge,
isScrollControlled: true,
),
onPressed: () {
feedBack();
showModalBottomSheet(
context: context,
builder: (_) => const SizedBox(
height: 450,
child: MinePage(),
),
clipBehavior: Clip.hardEdge,
isScrollControlled: true,
);
},
icon: const Icon(CupertinoIcons.person, size: 22),
),
),
Expand Down
2 changes: 2 additions & 0 deletions lib/pages/dynamics/widgets/action_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:get/get.dart';
import 'package:pilipala/http/dynamics.dart';
import 'package:pilipala/models/dynamics/result.dart';
import 'package:pilipala/pages/dynamics/index.dart';
import 'package:pilipala/utils/feed_back.dart';

class ActionPanel extends StatefulWidget {
const ActionPanel({
Expand All @@ -31,6 +32,7 @@ class _ActionPanelState extends State<ActionPanel> {

// 动态点赞
onLikeDynamic() async {
feedBack();
var item = widget.item!;
String dynamicId = item.idStr!;
// 1 已点赞 2 不喜欢 0 未操作
Expand Down
9 changes: 7 additions & 2 deletions lib/pages/dynamics/widgets/author_panel.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/utils.dart';

Widget author(item, context) {
Expand All @@ -10,12 +11,16 @@ Widget author(item, context) {
child: Row(
children: [
GestureDetector(
onTap: () => Get.toNamed(
onTap: () {
feedBack();
Get.toNamed(
'/member?mid=${item.modules.moduleAuthor.mid}',
arguments: {
'face': item.modules.moduleAuthor.face,
'heroTag': heroTag
}),
},
);
},
child: Hero(
tag: heroTag,
child: NetworkImgLayer(
Expand Down
5 changes: 4 additions & 1 deletion lib/pages/dynamics/widgets/up_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/models/dynamics/up.dart';
import 'package:pilipala/models/live/item.dart';
import 'package:pilipala/pages/dynamics/controller.dart';
import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/storage.dart';
import 'package:pilipala/utils/utils.dart';

Expand Down Expand Up @@ -81,7 +82,7 @@ class _UpPanelState extends State<UpPanel> {
),
Material(
child: InkWell(
onTap: () => Get.toNamed('/follow'),
onTap: () => {feedBack(), Get.toNamed('/follow')},
child: Container(
height: 100,
padding: const EdgeInsets.only(left: 10, right: 10),
Expand Down Expand Up @@ -111,6 +112,7 @@ class _UpPanelState extends State<UpPanel> {
bool isCurrent = currentMid == data.mid || currentMid == -1;
return InkWell(
onTap: () {
feedBack();
if (data.type == 'up') {
currentMid = data.mid;
Get.find<DynamicsController>().mid.value = data.mid;
Expand Down Expand Up @@ -149,6 +151,7 @@ class _UpPanelState extends State<UpPanel> {
}
},
onLongPress: () {
feedBack();
String heroTag = Utils.makeHeroTag(data.mid);
Get.toNamed('/member?mid=${data.mid}',
arguments: {'face': data.face, 'heroTag': heroTag});
Expand Down
10 changes: 8 additions & 2 deletions lib/pages/follow/widgets/follow_item.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/utils.dart';

Widget followItem({item}) {
String heroTag = Utils.makeHeroTag(item!.mid);
return ListTile(
onTap: () => Get.toNamed('/member?mid=${item.mid}',
arguments: {'face': item.face, 'heroTag': heroTag}),
onTap: () {
feedBack();
Get.toNamed('/member?mid=${item.mid}',
arguments: {'face': item.face, 'heroTag': heroTag});
},
leading: Hero(
tag: heroTag,
child: NetworkImgLayer(
Expand All @@ -19,6 +23,8 @@ Widget followItem({item}) {
),
title: Text(
item.uname,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(fontSize: 14),
),
subtitle: Text(
Expand Down
5 changes: 4 additions & 1 deletion lib/pages/home/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:get/get.dart';
import 'package:pilipala/pages/hot/index.dart';
import 'package:pilipala/pages/live/index.dart';
import 'package:pilipala/pages/rcmd/index.dart';
import 'package:pilipala/utils/feed_back.dart';
import './controller.dart';

class HomePage extends StatefulWidget {
Expand Down Expand Up @@ -92,7 +93,8 @@ class _HomePageState extends State<HomePage>
dividerColor: Colors.transparent,
unselectedLabelColor:
Theme.of(context).colorScheme.outline,
onTap: (value) => {_homeController.initialIndex = value},
onTap: (value) =>
{feedBack(), _homeController.initialIndex = value},
),
),
),
Expand All @@ -103,6 +105,7 @@ class _HomePageState extends State<HomePage>
tag: 'searchTag',
child: IconButton(
onPressed: () {
feedBack();
Get.toNamed('/search');
},
icon: const Icon(CupertinoIcons.search, size: 21),
Expand Down
2 changes: 2 additions & 0 deletions lib/pages/main/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/pages/dynamics/index.dart';
import 'package:pilipala/pages/home/index.dart';
import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/storage.dart';
import './controller.dart';

Expand Down Expand Up @@ -44,6 +45,7 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
}

void setIndex(int value) async {
feedBack();
if (selectedIndex != value) {
selectedIndex = value;
_animationController!.reverse().then((_) {
Expand Down
7 changes: 5 additions & 2 deletions lib/pages/member/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,19 @@ class _MemberPageState extends State<MemberPage>
const SizedBox(height: 14),
Row(
children: [
Text(
Expanded(
child: Text(
_memberController
.memberInfo.value.name!,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context)
.textTheme
.bodyLarge!
.copyWith(
fontWeight:
FontWeight.bold),
),
)),
const SizedBox(width: 2),
if (_memberController
.memberInfo.value.sex ==
Expand Down
12 changes: 12 additions & 0 deletions lib/pages/setting/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@ import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/http/init.dart';
import 'package:pilipala/pages/mine/controller.dart';
import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/storage.dart';

class SettingController extends GetxController {
Box user = GStrorage.user;
RxBool userLogin = false.obs;
Box userInfoCache = GStrorage.userInfo;
Box setting = GStrorage.setting;
RxBool feedBackEnable = false.obs;

@override
void onInit() {
super.onInit();
userLogin.value = user.get(UserBoxKey.userLogin) ?? false;
feedBackEnable.value =
setting.get(SettingBoxKey.feedBackEnable, defaultValue: false);
}

loginOut() async {
Expand All @@ -21,4 +26,11 @@ class SettingController extends GetxController {
userLogin.value = user.get(UserBoxKey.userLogin) ?? false;
userInfoCache.put('userInfoCache', null);
}

// 开启关闭震动反馈
onOpenFeedBack() {
feedBack();
feedBackEnable.value = !feedBackEnable.value;
setting.put(SettingBoxKey.feedBackEnable, feedBackEnable.value);
}
}
Loading

0 comments on commit e104864

Please sign in to comment.