Skip to content

Commit

Permalink
Improve faker ui
Browse files Browse the repository at this point in the history
  • Loading branch information
narumi147 committed Oct 17, 2024
1 parent 70cec76 commit 21696f8
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 102 deletions.
65 changes: 26 additions & 39 deletions lib/app/modules/faker/accounts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,7 @@ class _FakerAccountsPageState extends State<FakerAccountsPage> {
}

Widget itemBuilder(BuildContext context, AutoLoginData user) {
Widget child;
switch (user) {
case AutoLoginDataJP():
child = buildJP(context, user);
case AutoLoginDataCN():
child = buildCN(context, user);
}
Widget child = buildOne(context: context, user: user);

if (!sorting) {
child = Row(
Expand Down Expand Up @@ -161,47 +155,40 @@ class _FakerAccountsPageState extends State<FakerAccountsPage> {
return child;
}

Widget buildJP(BuildContext context, AutoLoginDataJP user) {
Widget buildOne({required BuildContext context, required AutoLoginData user}) {
return ListTile(
dense: true,
key: ObjectKey(user),
title: Text('[${user.region.upper}] ${user.userGame?.name}'),
subtitle: Text(user.userGame?.friendCode ?? user.auth?.userId.toString() ?? 'null'),
title: Text('[${user.serverName}] ${user.userGame?.name}'),
subtitle: Text(user.userGame?.friendCode ?? 'null'),
trailing: sorting
? null
: IconButton(
onPressed: () async {
await router.pushPage(FakerAccountEditPage(user: user));
if (mounted) setState(() {});
},
icon: const Icon(Icons.edit),
iconSize: 20,
: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
TimerUpdate(
duration: Duration(seconds: 60),
builder: (context, _) => user.userGame == null
? SizedBox.shrink()
: Text(
'${user.userGame?.calCurAp()}/${user.userGame?.actMax}',
style: Theme.of(context).textTheme.bodySmall,
),
),
IconButton(
onPressed: () async {
await router.pushPage(FakerAccountEditPage(user: user));
if (mounted) setState(() {});
},
icon: const Icon(Icons.edit),
iconSize: 20,
),
],
),
onTap: () {
router.pushPage(FakeGrandOrder(user: user));
},
);
}

Widget buildCN(BuildContext context, AutoLoginDataCN user) {
return ListTile(
dense: true,
key: ObjectKey(user),
title: Text('[${user.region.upper}-${user.gameServer.shownName}] ${user.nickname}'),
subtitle: Text(user.userGame?.friendCode ?? "UID ${user.uid}"),
trailing: sorting
? null
: IconButton(
onPressed: () async {
await router.pushPage(FakerAccountEditPage(user: user));
if (mounted) setState(() {});
},
icon: const Icon(Icons.edit),
iconSize: 20,
),
onTap: () async {
router.pushPage(FakeGrandOrder(user: user));
},
);
}
}
130 changes: 67 additions & 63 deletions lib/app/modules/faker/faker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,34 +129,44 @@ class _FakeGrandOrderState extends State<FakeGrandOrder> {
),
body: PopScope(
canPop: false,
child: Column(
children: [
headerInfo,
// const Divider(),
Expanded(
child: ListView(
children: [
optionSelector,
const Divider(height: 8),
battleDetailSection,
battleSetupOptionSection,
battleResultOptionSection,
battleLoopOptionSection,
uncommonSettingSection,
miscInfoSection,
notificationSettingSection,
globalSettingSection,
],
),
),
const Divider(height: 1),
buttonBar,
],
child: ListTileTheme.merge(
dense: true,
visualDensity: VisualDensity.compact,
// minVerticalPadding: 0,
// minTileHeight: 52,
child: body,
),
),
);
}

Widget get body {
return Column(
children: [
headerInfo,
// const Divider(),
Expanded(
child: ListView(
children: [
optionSelector,
const Divider(height: 8),
battleDetailSection,
battleSetupOptionSection,
battleResultOptionSection,
battleLoopOptionSection,
uncommonSettingSection,
miscInfoSection,
notificationSettingSection,
globalSettingSection,
],
),
),
const Divider(height: 1),
buttonBar,
],
);
}

Widget get headerInfo {
List<Widget> children = [];
final userGame = mstData.user ?? agent.user.userGame;
Expand Down Expand Up @@ -305,18 +315,10 @@ class _FakeGrandOrderState extends State<FakeGrandOrder> {
children.addAll([
ListTile(
dense: true,
title: Text('Quest ${battleEntity.questId}/${battleEntity.questPhase}'),
subtitle: Text(
title: Text(
_describeQuest(battleEntity.questId, battleEntity.questPhase,
battleEntity.battleInfo?.enemyDeck.map((e) => e.svts.length).join('-')),
),
onTap: () {
router.push(url: Routes.questI(battleEntity.questId, battleEntity.questPhase));
},
),
ListTile(
dense: true,
title: const Text('Drops'),
subtitle: Wrap(
children: [
for (final itemId in dropItems.keys.toList()..sort((a, b) => Item.compare2(a, b)))
Expand All @@ -338,6 +340,10 @@ class _FakeGrandOrderState extends State<FakeGrandOrder> {
),
],
),
trailing: Icon(DirectionalIcons.keyboard_arrow_forward(context)),
onTap: () {
router.push(url: Routes.questI(battleEntity.questId, battleEntity.questPhase));
},
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
Expand Down Expand Up @@ -428,7 +434,7 @@ class _FakeGrandOrderState extends State<FakeGrandOrder> {
header: battleEntity == null
? 'Battle Details'
: 'Battle ${battleEntity.id} - ${agent.curBattle == null ? "ended" : "ongoing"}'
' (${battleEntity.createdAt.sec2date().toStringShort()})',
' (${battleEntity.createdAt.sec2date().toCustomString(year: false)})',
children: children,
);
}
Expand Down Expand Up @@ -548,14 +554,14 @@ class _FakeGrandOrderState extends State<FakeGrandOrder> {
},
icon: const Icon(Icons.add_circle)),
),
SwitchListTile.adaptive(
CheckboxListTile.adaptive(
dense: true,
value: battleOption.waitApRecover,
title: const Text("Wait AP recover"),
onChanged: (v) {
runtime.lockTask(() {
setState(() {
battleOption.waitApRecover = v;
battleOption.waitApRecover = v!;
});
});
},
Expand Down Expand Up @@ -749,22 +755,20 @@ class _FakeGrandOrderState extends State<FakeGrandOrder> {
),
ListTile(
dense: true,
title: Text("Formation Deck - ${battleOption.deckId}"),
title: Text("Formation Deck ${battleOption.deckId}"),
subtitle: formation == null ? const Text("Unknown deck") : Text('${formation.deckNo} - ${formation.name}'),
trailing: IconButton(
onPressed: () {
runtime.lockTask(() {
router.pushPage(UserFormationDecksPage(
mstData: mstData,
onSelected: (v) {
battleOption.deckId = v.id;
if (mounted) setState(() {});
},
));
});
},
icon: const Icon(Icons.change_circle),
),
trailing: const Icon(Icons.change_circle),
onTap: () {
router.pushPage(UserFormationDecksPage(
mstData: mstData,
onSelected: (v) {
runtime.lockTask(() {
battleOption.deckId = v.id;
});
if (mounted) setState(() {});
},
));
},
),
if (formation != null) ...[
Padding(
Expand Down Expand Up @@ -932,7 +936,7 @@ class _FakeGrandOrderState extends State<FakeGrandOrder> {
),
),
const Divider(),
SwitchListTile.adaptive(
CheckboxListTile.adaptive(
dense: true,
value: battleOption.useCampaignItem,
secondary: Item.iconBuilder(context: context, item: null, itemId: 94065901, jumpToDetail: false),
Expand All @@ -949,19 +953,19 @@ class _FakeGrandOrderState extends State<FakeGrandOrder> {
onChanged: (v) {
runtime.lockTask(() {
setState(() {
battleOption.useCampaignItem = v;
battleOption.useCampaignItem = v!;
});
});
},
),
SwitchListTile.adaptive(
CheckboxListTile.adaptive(
dense: true,
value: battleOption.isApHalf,
title: const Text("During AP Half Event"),
onChanged: (v) {
runtime.lockTask(() {
setState(() {
battleOption.isApHalf = v;
battleOption.isApHalf = v!;
});
});
},
Expand Down Expand Up @@ -1075,27 +1079,27 @@ class _FakeGrandOrderState extends State<FakeGrandOrder> {
return TileGroup(
header: 'Other Options',
children: [
SwitchListTile.adaptive(
CheckboxListTile.adaptive(
dense: true,
value: battleOption.stopIfBondLimit,
title: const Text("Stop if Bond Limit"),
onChanged: (v) {
runtime.lockTask(() {
setState(() {
battleOption.stopIfBondLimit = v;
battleOption.stopIfBondLimit = v!;
});
});
},
controlAffinity: ListTileControlAffinity.trailing,
),
SwitchListTile.adaptive(
CheckboxListTile.adaptive(
dense: true,
value: battleOption.supportCeMaxLimitBreak,
title: Text('${S.current.support_servant} - ${S.current.craft_essence_short} ${S.current.max_limit_break}'),
onChanged: (v) {
runtime.lockTask(() {
setState(() {
battleOption.supportCeMaxLimitBreak = v;
battleOption.supportCeMaxLimitBreak = v!;
});
});
},
Expand All @@ -1116,14 +1120,14 @@ class _FakeGrandOrderState extends State<FakeGrandOrder> {
},
controlAffinity: ListTileControlAffinity.trailing,
),
SwitchListTile.adaptive(
CheckboxListTile.adaptive(
dense: true,
value: battleOption.enfoceRefreshSupport,
title: const Text("Force Refresh Support"),
onChanged: (v) {
runtime.lockTask(() {
setState(() {
battleOption.enfoceRefreshSupport = v;
battleOption.enfoceRefreshSupport = v!;
});
});
},
Expand Down Expand Up @@ -1277,13 +1281,13 @@ class _FakeGrandOrderState extends State<FakeGrandOrder> {
child: Text(fakerSettings.maxFollowerListRetryCount.toString())),
),
const Divider(),
SwitchListTile.adaptive(
CheckboxListTile.adaptive(
dense: true,
value: fakerSettings.dumpResponse,
title: const Text('Dump Responses'),
onChanged: (v) {
setState(() {
fakerSettings.dumpResponse = v;
fakerSettings.dumpResponse = v!;
});
},
),
Expand Down Expand Up @@ -1428,7 +1432,7 @@ class _FakeGrandOrderState extends State<FakeGrandOrder> {
title: 'Start Looping Battle',
keyboardType: TextInputType.number,
autofocus: battleOption.loopCount <= 0,
text: battleOption.loopCount.toString(),
text: (battleOption.loopCount == 0 ? 1 : battleOption.loopCount).toString(),
validate: (s) => (int.tryParse(s) ?? -1) > 0,
onSubmit: (s) {
battleOption.loopCount = int.parse(s);
Expand Down
12 changes: 12 additions & 0 deletions lib/app/modules/faker/history.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ class _FakerHistoryViewerState extends State<FakerHistoryViewer> {
appBar: AppBar(
title: Text("History (${history.length})"),
actions: [
IconButton(
onPressed: () {
setState(() {});
},
icon: Icon(Icons.replay),
),
IconButton(
onPressed: () {
final history = agent.network.history;
Expand Down Expand Up @@ -124,6 +130,12 @@ class _FakerHistoryViewerState extends State<FakerHistoryViewer> {
Map? data;
if (detail.isSuccess()) {
data = detail.success;
if (detail.nid == 'gamedata' && data != null) {
data = {
for (final (k, v) in data.items)
k: const {'webview', 'assetbundle', 'master', 'assetbundleKey'}.contains(k) && v != '' ? '...' : v
};
}
if (data?.isNotEmpty != true && detail.fail?.isNotEmpty == true) {
data = detail.fail;
}
Expand Down

0 comments on commit 21696f8

Please sign in to comment.