Skip to content

Commit

Permalink
fix: UI adjust & fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MuZhou233 committed Sep 26, 2024
1 parent ba481d4 commit 3fd8948
Show file tree
Hide file tree
Showing 9 changed files with 358 additions and 208 deletions.
3 changes: 2 additions & 1 deletion lib/bloc/yesod/yesod_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class YesodBloc extends Bloc<YesodEvent, YesodState> {
}
final configs = [
ListFeedConfigsResponse_FeedWithConfig(
config: event.config,
config: event.config..id = resp.getData().id,
feed: null,
)
];
Expand Down Expand Up @@ -222,6 +222,7 @@ class YesodBloc extends Bloc<YesodEvent, YesodState> {
event.set,
];
sets.addAll(state.feedActionSets ?? []);
add(YesodFeedActionSetLoadEvent());
emit(YesodFeedActionSetAddState(
state.copyWith(feedActionSets: sets),
EventStatus.success,
Expand Down
1 change: 1 addition & 0 deletions lib/route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ class YesodFunctionRoute extends GoRouteData {
case YesodFunctions.recent:
case YesodFunctions.timeline:
context.read<YesodBloc>().add(YesodInitEvent());
context.read<YesodBloc>().add(YesodFeedConfigLoadEvent());
case YesodFunctions.feedManage:
context.read<MainBloc>().add(MainRefreshServerInfoEvent());
context.read<YesodBloc>().add(YesodFeedConfigLoadEvent());
Expand Down
63 changes: 63 additions & 0 deletions lib/view/components/pop_alert.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import 'package:flutter/material.dart';

class PopAlert extends StatelessWidget {
const PopAlert({
super.key,
required this.child,
required this.title,
required this.content,
required this.onConfirm,
this.onDeny,
required this.onCancel,
});

final Widget child;
final String title;
final String content;
final void Function() onConfirm;
final void Function()? onDeny;
final void Function() onCancel;

@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () async {
final shouldPop = await showDialog<bool>(
context: context,
builder: (context) {
return AlertDialog(
title: Text(title),
content: Text(content),
actions: [
TextButton(
onPressed: () => {
Navigator.of(context).pop(true),
onConfirm(),
},
child: const Text('是'),
),
if (onDeny != null)
TextButton(
onPressed: () => {
Navigator.of(context).pop(true),
onDeny!(),
},
child: const Text('否'),
),
TextButton(
onPressed: () => {
Navigator.of(context).pop(false),
onCancel(),
},
child: const Text('点错了'),
),
],
);
},
);
return shouldPop ?? false;
},
child: child,
);
}
}
15 changes: 10 additions & 5 deletions lib/view/components/toast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,27 @@ class Toast {

ScaffoldFeatureController<SnackBar, SnackBarClosedReason> show(
BuildContext context) {
final messenger = ScaffoldMessenger.of(context);
final left = calculateColumnWidth(
xxs: 0,
sm: 6,
md: 8,
xl: 10,
containerWidth: MediaQuery.of(context).size.width,
);
return ScaffoldMessenger.of(context).showSnackBar(
return messenger.showSnackBar(
SnackBar(
elevation: 0,
margin: EdgeInsets.only(left: left),
behavior: SnackBarBehavior.floating,
hitTestBehavior: HitTestBehavior.deferToChild,
backgroundColor: Colors.transparent,
content: _content(context),
content: _content(context, messenger),
),
);
}

Widget _content(BuildContext context) {
Widget _content(BuildContext context, ScaffoldMessengerState messenger) {
final List<Widget> maybeActionAndIcon = <Widget>[
if (action != null)
Padding(
Expand Down Expand Up @@ -85,8 +86,12 @@ class Toast {
IconButton(
icon: const Icon(Icons.close),
color: Theme.of(context).colorScheme.onPrimary,
onPressed: () => ScaffoldMessenger.of(context)
.hideCurrentSnackBar(reason: SnackBarClosedReason.dismiss),
onPressed: () {
if (messenger.mounted) {
messenger.hideCurrentSnackBar(
reason: SnackBarClosedReason.dismiss);
}
},
),
],
),
Expand Down
48 changes: 44 additions & 4 deletions lib/view/pages/yesod/manage_notify_flow_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,16 @@ class _NotifyFlowAddPanelState extends State<NotifyFlowAddPanel> {
MultiSelectItem(
config.config.id, config.feed.title),
],
itemsTextStyle: TextStyle(
fontSize:
Theme.of(context).textTheme.bodyMedium?.fontSize,
color: Theme.of(context).colorScheme.onSurface,
),
selectedItemsTextStyle: TextStyle(
fontSize:
Theme.of(context).textTheme.bodyMedium?.fontSize,
color: Theme.of(context).colorScheme.onSurface,
),
initialValue: sources.map((e) => e.feedConfigId).toList(),
onConfirm: (values) {
final List<NotifyFlowSourceModel> newSources = [];
Expand Down Expand Up @@ -349,6 +359,16 @@ class _NotifyFlowAddPanelState extends State<NotifyFlowAddPanel> {
if (config.id.id != 0)
MultiSelectItem(config.id, config.name),
],
itemsTextStyle: TextStyle(
fontSize:
Theme.of(context).textTheme.bodyMedium?.fontSize,
color: Theme.of(context).colorScheme.onSurface,
),
selectedItemsTextStyle: TextStyle(
fontSize:
Theme.of(context).textTheme.bodyMedium?.fontSize,
color: Theme.of(context).colorScheme.onSurface,
),
initialValue: targets.map((e) => e.targetId).toList(),
onConfirm: (values) {
final List<NotifyFlowTargetModel> newTargets = [];
Expand Down Expand Up @@ -652,9 +672,19 @@ class _NotifyFlowAddPageState extends State<NotifyFlowEditPanel> {
for (final ListFeedConfigsResponse_FeedWithConfig config
in notifySources)
if (config.config.id.id != 0)
MultiSelectItem(
config.config.id, config.feed.title),
MultiSelectItem(config.config.id,
'${config.config.name} - ${config.feed.title}'),
],
itemsTextStyle: TextStyle(
fontSize:
Theme.of(context).textTheme.bodyMedium?.fontSize,
color: Theme.of(context).colorScheme.onSurface,
),
selectedItemsTextStyle: TextStyle(
fontSize:
Theme.of(context).textTheme.bodyMedium?.fontSize,
color: Theme.of(context).colorScheme.onSurface,
),
initialValue: sources.map((e) => e.feedConfigId).toList(),
onConfirm: (values) {
final List<NotifyFlowSourceModel> newSources = [];
Expand Down Expand Up @@ -696,8 +726,8 @@ class _NotifyFlowAddPageState extends State<NotifyFlowEditPanel> {
child: Text(notifySources
.firstWhere(
(e) => e.config.id == sources[i].feedConfigId)
.feed
.title),
.config
.name),
),
const SizedBox(
height: 8,
Expand Down Expand Up @@ -823,6 +853,16 @@ class _NotifyFlowAddPageState extends State<NotifyFlowEditPanel> {
if (config.id.id != 0)
MultiSelectItem(config.id, config.name),
],
itemsTextStyle: TextStyle(
fontSize:
Theme.of(context).textTheme.bodyMedium?.fontSize,
color: Theme.of(context).colorScheme.onSurface,
),
selectedItemsTextStyle: TextStyle(
fontSize:
Theme.of(context).textTheme.bodyMedium?.fontSize,
color: Theme.of(context).colorScheme.onSurface,
),
initialValue: targets.map((e) => e.targetId).toList(),
onConfirm: (values) {
final List<NotifyFlowTargetModel> newTargets = [];
Expand Down
Loading

0 comments on commit 3fd8948

Please sign in to comment.