mirror of
https://github.com/zoriya/Aeris.git
synced 2026-06-02 10:57:31 +00:00
Mobile Client: Display parameters in pipeline detail page
This commit is contained in:
@@ -149,8 +149,15 @@ class AerisAPI {
|
||||
var res = await _requestAPI('/workflows', AerisAPIRequestType.get, null);
|
||||
if (res.ok == false) return [];
|
||||
final List body = jsonDecode(res.body);
|
||||
|
||||
return body.map((e) => Pipeline.fromJSON(Map.from(e))).toList();
|
||||
var decodedList = body.map((e) => Pipeline.fromJSON(Map.from(e))).toList();
|
||||
decodedList.add(
|
||||
Pipeline(id: 0, name: "My Dummy", triggerCount: 0, enabled: true, trigger:
|
||||
Trigger(name: "Trigger name", displayName: "Trigger Display", service: Service.discord(), parameters: [for (var i = 0; i < 3; i++) ActionParameter(name: "para$i", value: "value$i", description: "desc$i")]
|
||||
), reactions: [
|
||||
Reaction(service: const Service.anilist(), name: "Reaction name", displayName: "Reaction display", parameters: [for (var i = 0; i < 3; i++) ActionParameter(name: "para$i", value: "value$i", description: "desc$i")])
|
||||
])
|
||||
);
|
||||
return decodedList;
|
||||
}
|
||||
|
||||
/// Fetch the services the user is authenticated to
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:aeris/src/widgets/action_detail_card.dart';
|
||||
import 'package:aeris/src/widgets/reorderable_reaction_cards_list.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||
@@ -7,7 +8,6 @@ import 'package:aeris/src/models/trigger.dart';
|
||||
import 'package:aeris/src/providers/pipelines_provider.dart';
|
||||
import 'package:aeris/src/views/pipeline_detail_page.dart';
|
||||
import 'package:aeris/src/views/setup_action_page.dart';
|
||||
import 'package:aeris/src/widgets/action_card.dart';
|
||||
import 'package:aeris/src/widgets/action_card_popup_menu.dart';
|
||||
import 'package:aeris/src/widgets/aeris_card_page.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
@@ -91,11 +91,9 @@ class _CreatePipelinePageState extends State<CreatePipelinePage> {
|
||||
reactions))
|
||||
.then((_) => setState(() {}));
|
||||
})
|
||||
: ActionCard(
|
||||
leading: trigger.service
|
||||
.getLogo(logoSize: 50),
|
||||
title: trigger.displayName,
|
||||
trailing: ActionCardPopupMenu(
|
||||
: ActionDetailCard(
|
||||
action: trigger,
|
||||
popupMenu: ActionCardPopupMenu(
|
||||
deletable: false,
|
||||
parentReactions: reactions,
|
||||
parentTrigger: trigger,
|
||||
@@ -114,13 +112,11 @@ class _CreatePipelinePageState extends State<CreatePipelinePage> {
|
||||
child: ReorderableReactionCardsList(
|
||||
reactionList: reactions,
|
||||
onReorder: () {},
|
||||
itemBuilder: (reaction) => ActionCard(
|
||||
itemBuilder: (reaction) => ActionDetailCard(
|
||||
key: ValueKey(
|
||||
reactions.indexOf(reaction)),
|
||||
leading: reaction.service
|
||||
.getLogo(logoSize: 50),
|
||||
title: reaction.displayName,
|
||||
trailing: ActionCardPopupMenu(
|
||||
action: reaction,
|
||||
popupMenu: ActionCardPopupMenu(
|
||||
parentTrigger:
|
||||
trigger == Trigger.template()
|
||||
? null
|
||||
|
||||
@@ -2,11 +2,11 @@ import 'package:aeris/src/aeris_api.dart';
|
||||
import 'package:aeris/src/providers/pipelines_provider.dart';
|
||||
import 'package:aeris/src/views/setup_action_page.dart';
|
||||
import 'package:aeris/src/widgets/action_card_popup_menu.dart';
|
||||
import 'package:aeris/src/widgets/action_detail_card.dart';
|
||||
import 'package:aeris/src/widgets/aeris_card_page.dart';
|
||||
import 'package:aeris/src/widgets/colored_clickable_card.dart';
|
||||
import 'package:aeris/src/widgets/reorderable_reaction_cards_list.dart';
|
||||
import 'package:aeris/src/widgets/warning_dialog.dart';
|
||||
import 'package:aeris/src/widgets/action_card.dart';
|
||||
import 'package:flutter_switch/flutter_switch.dart';
|
||||
import 'package:aeris/src/models/reaction.dart';
|
||||
import 'package:aeris/src/models/pipeline.dart';
|
||||
@@ -137,10 +137,9 @@ class _PipelineDetailPageState extends State<PipelineDetailPage> {
|
||||
),
|
||||
Text(AppLocalizations.of(context).action,
|
||||
style: const TextStyle(fontWeight: FontWeight.w500)),
|
||||
ActionCard(
|
||||
leading: pipeline.trigger.service.getLogo(logoSize: 50),
|
||||
title: pipeline.trigger.displayName,
|
||||
trailing: ActionCardPopupMenu(
|
||||
ActionDetailCard(
|
||||
action: pipeline.trigger,
|
||||
popupMenu: ActionCardPopupMenu(
|
||||
deletable: false,
|
||||
parentTrigger: pipeline.trigger,
|
||||
parentReactions: pipeline.reactions,
|
||||
@@ -155,11 +154,10 @@ class _PipelineDetailPageState extends State<PipelineDetailPage> {
|
||||
ReorderableReactionCardsList(
|
||||
onReorder: () => GetIt.I<AerisAPI>().editPipeline(pipeline),
|
||||
reactionList: pipeline.reactions,
|
||||
itemBuilder: (reaction) => ActionCard(
|
||||
itemBuilder: (reaction) => ActionDetailCard(
|
||||
key: ValueKey(pipeline.reactions.indexOf(reaction)),
|
||||
leading: reaction.service.getLogo(logoSize: 50),
|
||||
title: reaction.displayName,
|
||||
trailing: ActionCardPopupMenu(
|
||||
action: reaction,
|
||||
popupMenu: ActionCardPopupMenu(
|
||||
parentTrigger: pipeline.trigger,
|
||||
parentReactions: pipeline.reactions,
|
||||
deletable: pipeline.reactions.length > 1,
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:aeris/src/models/service.dart';
|
||||
import 'package:aeris/src/providers/pipelines_provider.dart';
|
||||
import 'package:aeris/src/providers/services_provider.dart';
|
||||
import 'package:aeris/src/widgets/action_card.dart';
|
||||
import 'package:aeris/src/widgets/service_card.dart';
|
||||
import 'package:aeris/src/widgets/aeris_card_page.dart';
|
||||
import 'package:aeris/src/widgets/warning_dialog.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -23,7 +23,7 @@ class ServicePage extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
for (var service in services)
|
||||
ActionCard(
|
||||
ServiceCard(
|
||||
leading: service.getLogo(logoSize: 50),
|
||||
title: service.name,
|
||||
trailing: IconButton(
|
||||
|
||||
@@ -112,7 +112,10 @@ class _SetupActionPageState extends State<SetupActionPage> {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Text(AppLocalizations.of(context).paramInheritTip),
|
||||
Text(
|
||||
AppLocalizations.of(context).paramInheritTip,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.onSurface)
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
if (availableActions == null)
|
||||
SkeletonLoader(
|
||||
|
||||
@@ -47,7 +47,7 @@ class ActionCardPopupMenu extends StatelessWidget {
|
||||
dynamic Function() callback = value! as dynamic Function();
|
||||
callback();
|
||||
},
|
||||
icon: Icons.more_vert,
|
||||
icon: Icons.more_horiz,
|
||||
itemBuilder: (context) => [
|
||||
AerisPopupMenuItem(
|
||||
context: context,
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
import 'package:aeris/src/models/action.dart' as aeris;
|
||||
import 'package:aeris/src/models/action_parameter.dart';
|
||||
import 'package:expandable/expandable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ActionDetailCard extends StatelessWidget {
|
||||
///The source of information
|
||||
final aeris.Action action;
|
||||
///The popup menu to update action
|
||||
final Widget popupMenu;
|
||||
|
||||
const ActionDetailCard(
|
||||
{Key? key,
|
||||
required this.action,
|
||||
required this.popupMenu})
|
||||
: super(key: key);
|
||||
|
||||
Widget paramView(BuildContext context, ActionParameter parameter) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Chip(
|
||||
backgroundColor: Theme.of(context).colorScheme.secondary,
|
||||
label: Text(parameter.name,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.onSecondary
|
||||
)
|
||||
),
|
||||
),
|
||||
Flexible(child: Padding(
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
child: Text(parameter.value!.toString(), overflow: TextOverflow.ellipsis)
|
||||
))
|
||||
]
|
||||
),
|
||||
Text(parameter.description,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
)
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
elevation: 5,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20))
|
||||
),
|
||||
child: ExpandableNotifier(
|
||||
child: ScrollOnExpand(
|
||||
child: ExpandablePanel(
|
||||
collapsed: Container(),
|
||||
header: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 15, top: 15, left: 15, right: 6),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: action.service.getLogo(logoSize: 50), flex: 2),
|
||||
Expanded(
|
||||
child: Text(
|
||||
action.displayName,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
fontSize: 15
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
flex: 8
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
expanded: Padding(
|
||||
padding: const EdgeInsets.only(left: 30, right: 30, bottom: 20, top: 10),
|
||||
child: action.parameters.isEmpty
|
||||
? Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text("No parameter"), //TODO translta
|
||||
popupMenu
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: popupMenu,
|
||||
),
|
||||
...[for (var parameter in action.parameters)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
child: paramView(context, parameter)
|
||||
)]
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ActionCard extends StatelessWidget {
|
||||
class ServiceCard extends StatelessWidget {
|
||||
///Leading widget (like an icon) on the left
|
||||
final Widget leading;
|
||||
|
||||
@@ -10,7 +10,7 @@ class ActionCard extends StatelessWidget {
|
||||
///Widget on the right of the card
|
||||
final Widget trailing;
|
||||
|
||||
const ActionCard(
|
||||
const ServiceCard(
|
||||
{Key? key,
|
||||
required this.leading,
|
||||
required this.title,
|
||||
Reference in New Issue
Block a user