Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ekran skanowania lista wyników #135

Merged
merged 23 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions assets/menuPage/flashlightoff.svg
WezSieTato marked this conversation as resolved.
Show resolved Hide resolved
WezSieTato marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions assets/menuPage/flashlighton.svg
WezSieTato marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 55 additions & 26 deletions lib/pages/scan/companies_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,59 @@ class CompaniesList extends StatelessWidget {
@override
Widget build(BuildContext context) {
_scrollToTop();
return Column(mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[
Container(
height: 200,
child: Align(
alignment: Alignment.bottomCenter,
child: ListView.builder(
controller: listScrollController,
reverse: true,
itemCount: state.list.length + (state.isLoading ? 1 : 0),
itemBuilder: (BuildContext context, int index) {
if (index == state.list.length) {
return LoadingListItem();
}
return GestureDetector(
child: ResultListItem(state.list[index]),
onTap: () {
final result = state.list[index];
_analytics.opensCard(result);
Navigator.pushNamed(context, '/detail', arguments: result);
},
);
},
return Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Container(
height: 200,
WezSieTato marked this conversation as resolved.
Show resolved Hide resolved
child: Align(
alignment: Alignment.bottomCenter,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: ListView.builder(
controller: listScrollController,
reverse: true,
itemCount: state.list.length + (state.isLoading ? 1 : 0) + 1,
itemBuilder: (BuildContext context, int index) {
if (index == state.list.length + (state.isLoading ? 1 : 0)) {
return Padding(
padding: const EdgeInsets.only(left: 16.0, top: 8.0),
child: Text(
'Ostatnie skany:',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
);
}

if (index == state.list.length && state.isLoading) {
return LoadingListItem();
}

final result = state.list[reverseIndex(index)];
return GestureDetector(
child: ResultListItem(result),
onTap: () {
_analytics.opensCard(result);
Navigator.pushNamed(context, '/detail', arguments: result);
},
);
},
),
),
],
),
),
),
),
RemoteButton(RemoteButtonState(
state.list.firstOrNull?.donate, state.list.firstOrNull?.code))
]);
RemoteButton(RemoteButtonState(
state.list.firstOrNull?.donate, state.list.firstOrNull?.code))
],
);
}

void _scrollToTop() {
Expand All @@ -52,4 +77,8 @@ class CompaniesList extends StatelessWidget {
}
});
}

int reverseIndex(int index) {
return state.list.length - 1 - index;
}
}
34 changes: 26 additions & 8 deletions lib/pages/scan/scan.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class _MainPageState extends State<MainPage> {
final PolaAnalytics _analytics = PolaAnalytics.instance();

ScrollController listScrollController = ScrollController();
bool _isTorchOn = false;

@override
void initState() {
Expand All @@ -46,10 +47,9 @@ class _MainPageState extends State<MainPage> {
onPressed: () {
_analytics.aboutPolaOpened();
showWebViewDialog(
context: context,
url: "https://www.pola-app.pl/m/about",
title: t.menu.aboutPola
);
context: context,
url: "https://www.pola-app.pl/m/about",
title: t.menu.aboutPola);
},
icon: Assets.icLauncher.image(),
),
Expand Down Expand Up @@ -114,13 +114,16 @@ class _MainPageState extends State<MainPage> {
builder: (_) {
return AlertDialog(
title: Text('Wystąpił błąd'),
content: Text('Niestety nie udało się pobrać danych. Spróbuj ponownie.'),
content: Text(
'Niestety nie udało się pobrać danych. Spróbuj ponownie.'),
WezSieTato marked this conversation as resolved.
Show resolved Hide resolved
actions: <Widget>[
TextButton(
child: Text('Zamknij.'),
onPressed: () {
_scanBloc.add(ScanEvent.alertDialogDismissed());
SchedulerBinding.instance.addPostFrameCallback((_) {
_scanBloc
.add(ScanEvent.alertDialogDismissed());
SchedulerBinding.instance
.addPostFrameCallback((_) {
Navigator.pop(context);
});
},
Expand All @@ -129,13 +132,28 @@ class _MainPageState extends State<MainPage> {
);
},
);
});
});
}
return CompaniesList(state, listScrollController);
},
),
],
)),
Positioned(
bottom: 20,
right: 20,
child: GestureDetector(
onTap: () {
setState(() {
_isTorchOn = !_isTorchOn;
cameraController.toggleTorch();
});
},
child: _isTorchOn
? Assets.menuPage.flashlighton.svg()
: Assets.menuPage.flashlightoff.svg(),
),
),
],
),
extendBodyBehindAppBar: true,
Expand Down
9 changes: 8 additions & 1 deletion lib/theme/assets.gen.dart

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

Loading
Loading