Skip to content

Commit

Permalink
so begins fishing data
Browse files Browse the repository at this point in the history
  • Loading branch information
SlayerOrnstein committed Mar 25, 2024
1 parent b11860b commit a8fd87e
Show file tree
Hide file tree
Showing 58 changed files with 1,932 additions and 28 deletions.
6 changes: 0 additions & 6 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
include: package:very_good_analysis/analysis_options.yaml

analyzer:
plugins:
- dart_code_metrics
exclude:
- lib/generated/l10n.dart
- lib/generated/intl/messages_*.dart
- lib/src/**/*g.dart
- lib/src/models/**/*.g.dart
- lib/firebase_options.dart

linter:
Expand Down
2 changes: 2 additions & 0 deletions lib/app/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:feedback_sentry/feedback_sentry.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:navis/codex/codex.dart';
import 'package:navis/explore/views/fish_view.dart';
import 'package:navis/home/home.dart';
import 'package:navis/l10n/l10n.dart';
import 'package:navis/settings/settings.dart';
Expand Down Expand Up @@ -175,6 +176,7 @@ class _NavisAppState extends State<NavisApp> with WidgetsBindingObserver {
BaroInventory.route: (_) => const BaroInventory(),
SynthTargetsView.route: (_) => const SynthTargetsView(),
'/codex': (_) => const CodexSearchPage(),
'/fish': (_) => const FishPage(),
},
supportedLocales: NavisLocalizations.supportedLocales,
locale: language,
Expand Down
98 changes: 98 additions & 0 deletions lib/explore/views/fish_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import 'package:fish_repository/fish_repository.dart';
import 'package:flutter/material.dart';
import 'package:navis/explore/widgets/fish_card.dart';

class FishPage extends StatelessWidget {
const FishPage({super.key});

@override
Widget build(BuildContext context) {
return const Scaffold(body: FishView());
}
}

class FishView extends StatelessWidget {
const FishView({super.key});

@override
Widget build(BuildContext context) {
const tabs = [
{'name': 'Deimos', 'region': FishingRegion.deimos},
{'name': 'Plains of Eidolon', 'region': FishingRegion.poe},
{'name': 'Orb Vallis', 'region': FishingRegion.vallis}
];

return DefaultTabController(
length: tabs.length,
child: NestedScrollView(
floatHeaderSlivers: true,
headerSliverBuilder: (context, innerBoxIsScrolled) {
// These are the slivers that show up in the "outer" scroll view.
return <Widget>[
SliverOverlapAbsorber(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
sliver: SliverAppBar(
title: const Text('Fishing data'),
floating: true,
forceElevated: innerBoxIsScrolled,
bottom: TabBar(
tabs:
tabs.map((r) => Tab(text: r['name']! as String)).toList(),
),
),
),
];
},
body: TabBarView(
// These are the contents of the tab views, below the tabs.
children: tabs.map((r) {
return SafeArea(
top: false,
bottom: false,
child: Builder(
builder: (BuildContext context) {
// ignore: strict_raw_type
return FutureBuilder<List<Fish>>(
// ignore: inference_failure_on_function_invocation
future: loadFishResources(r['region']! as FishingRegion),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const Center(child: CircularProgressIndicator());
}

final data = snapshot.data;

return CustomScrollView(
key: PageStorageKey<String>(r['name']! as String),
slivers: <Widget>[
SliverOverlapInjector(
// This is the flip side of the SliverOverlapAbsorber
// above.
handle:
NestedScrollView.sliverOverlapAbsorberHandleFor(
context),
),
SliverPadding(
padding: const EdgeInsets.all(8),
sliver: SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return FishCard(fish: data[index]);
},
childCount: data!.length,
),
),
),
],
);
},
);
},
),
);
}).toList(),
),
),
);
}
}
1 change: 1 addition & 0 deletions lib/explore/views/main_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ExploreView extends StatelessWidget {
leading: const Icon(WarframeSymbols.menu_FishLarge, size: iconSize),
title: Text(l10n.fishTitle),
subtitle: Text(l10n.fishDescription),
onTap: () => Navigator.of(context).pushNamed('/fish'),
),
),
AppCard(
Expand Down
193 changes: 193 additions & 0 deletions lib/explore/widgets/fish_card.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
import 'package:fish_repository/fish_repository.dart';
import 'package:flutter/material.dart';
import 'package:navis_ui/navis_ui.dart';

class FishCard extends StatelessWidget {
const FishCard({super.key, required this.fish});

// ignore: strict_raw_type
final Fish fish;

@override
Widget build(BuildContext context) {
return Card(
child: AnimatedContainer(
duration: const Duration(milliseconds: 300),
padding: const EdgeInsets.all(8),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const CategoryTitle(title: 'Name'),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
fish.name,
style: Theme.of(context).textTheme.titleMedium,
),
if (fish.small.standing != null)
Text(
'Standing: '
'${fish.small.standing}'
'/${fish.medium.standing}'
'/${fish.large.standing}',
style: Theme.of(context).textTheme.titleSmall?.copyWith(
color: Colors.grey[400],
),
),
],
),
),
if (!fish.name.contains('Boot')) ...{
const CategoryTitle(title: 'Unique Resources'),
_BuildUniqueResources(uniqueResources: fish.uniqueResources),
},
if (!fish.name.contains('Boot')) ...{
const CategoryTitle(title: 'Resources S/M/L'),
_BuildResources(
small: fish.small.resources,
medium: fish.medium.resources,
large: fish.large.resources,
),
}
],
),
),
);
}
}

class _BuildUniqueResources<T> extends StatelessWidget {
const _BuildUniqueResources({super.key, required this.uniqueResources});

final T uniqueResources;

@override
Widget build(BuildContext context) {
Widget resources;
if (uniqueResources is List<UniqueResource>) {
resources = Wrap(
children: (uniqueResources as List<UniqueResource>).map(
(r) {
return ColoredContainer(
tooltip: r.name,
child: Text(r.name),
);
},
).toList(),
);
} else {
resources = ColoredContainer(
tooltip: (uniqueResources as UniqueResource).name,
child: Text((uniqueResources as UniqueResource).name),
);
}

return Padding(
padding: const EdgeInsets.symmetric(horizontal: 14),
child: resources,
);
}
}

class _BuildResources extends StatelessWidget {
const _BuildResources({
required this.small,
required this.medium,
required this.large,
});

final RegionResources small;
final RegionResources medium;
final RegionResources large;

@override
Widget build(BuildContext context) {
Widget widget;
// Check small and assume the reset are all from the same region.
if (small is DeimosRegionResources) {
final small = this.small as DeimosRegionResources;
final medium = this.medium as DeimosRegionResources;
final large = this.large as DeimosRegionResources;

widget = Wrap(
children: [
if (small.bladder > 1)
ColoredContainer(
tooltip: 'Bladder',
child: Text(
'Bladder: '
'${small.bladder}/${medium.bladder}/${large.bladder}',
),
),
if (small.gills > 1)
ColoredContainer(
tooltip: 'Gills',
child: Text(
'Gills: '
'${small.gills}/${medium.gills}/${large.gills}',
),
),
if (small.tumor > 1)
ColoredContainer(
tooltip: 'Tumor',
child: Text(
'Tumor: '
'${small.tumor}/${medium.tumor}/${large.tumor}',
),
),
],
);
} else if (small is PoeRegionResources) {
final small = this.small as PoeRegionResources;
final medium = this.medium as PoeRegionResources;
final large = this.large as PoeRegionResources;

widget = Wrap(
children: [
if (small.meat > 1)
ColoredContainer(
tooltip: 'Meat',
child: Text(
'Meat: '
'${small.meat}/${medium.meat}/${large.meat}',
),
),
if (small.oil > 1)
ColoredContainer(
tooltip: 'Oil',
child: Text(
'Oil: '
'${small.oil}/${medium.oil}/${large.oil}',
),
),
if (small.scales > 1)
ColoredContainer(
tooltip: 'Scales',
child: Text(
'Scales: '
'${small.scales}/${medium.scales}/${large.scales}',
),
),
],
);
} else {
final small = this.small as VallisRegionResources;
final medium = this.medium as VallisRegionResources;
final large = this.large as VallisRegionResources;

widget = ColoredContainer(
tooltip: 'Scrap',
child: Text('Scrap: ${small.scrap}/${medium.scrap}/${large.scrap}'),
);
}

return Padding(
padding: const EdgeInsets.symmetric(horizontal: 14),
child: widget,
);
}
}
17 changes: 0 additions & 17 deletions lib/gen/assets.gen.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions packages/fish_repository/.github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Bug Report
about: Create a report to help us improve
title: "fix: "
labels: bug
---

**Description**

A clear and concise description of what the bug is.

**Steps To Reproduce**

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected Behavior**

A clear and concise description of what you expected to happen.

**Screenshots**

If applicable, add screenshots to help explain your problem.

**Additional Context**

Add any other context about the problem here.
Loading

0 comments on commit a8fd87e

Please sign in to comment.