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 16 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
Binary file removed assets/ic_flash_off_white_48dp.png
Binary file not shown.
Binary file removed assets/ic_flash_on_white_48dp.png
Binary file not shown.
8 changes: 8 additions & 0 deletions assets/menuPage/showmore.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/scan/flashlightOff.svg
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/scan/flashlightOn.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 14 additions & 2 deletions lib/i18n/strings.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
/// To regenerate, run: `dart run slang`
///
/// Locales: 1
/// Strings: 22
/// Strings: 28
///
/// Built on 2024-08-21 at 08:34 UTC
/// Built on 2024-09-24 at 17:35 UTC

// coverage:ignore-file
// ignore_for_file: type=lint
Expand Down Expand Up @@ -199,6 +199,12 @@ class _StringsScanEn {

// Translations
String get scanning => 'Skanowanie';
String get tryAgain => 'Niestety nie udało się pobrać danych. Spróbuj ponownie.';
String get pkt => ' pkt';
String get wait => 'Proszę czekać, trwa Ładowanie...';
String get lastScans => 'Ostatnie skany:';
String get error => 'Wystąpił błąd';
String get closeError => 'Zamknij.';
}

/// Flat map(s) containing all translations.
Expand Down Expand Up @@ -229,6 +235,12 @@ extension on Translations {
case 'companyScreen.companyFriend': return ' Ta firma jest przyjacielem Poli';
case 'companyScreen.polaFriends': return 'Przyjaciele Poli';
case 'scan.scanning': return 'Skanowanie';
case 'scan.tryAgain': return 'Niestety nie udało się pobrać danych. Spróbuj ponownie.';
case 'scan.pkt': return ' pkt';
case 'scan.wait': return 'Proszę czekać, trwa Ładowanie...';
case 'scan.lastScans': return 'Ostatnie skany:';
case 'scan.error': return 'Wystąpił błąd';
case 'scan.closeError': return 'Zamknij.';
default: return null;
}
}
Expand Down
9 changes: 8 additions & 1 deletion lib/i18n/strings.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
"polaFriends": "Przyjaciele Poli"
},
"scan": {
"scanning": "Skanowanie"
"scanning": "Skanowanie",
"tryAgain": "Niestety nie udało się pobrać danych. Spróbuj ponownie.",
"pkt":" pkt",
"wait": "Proszę czekać, trwa Ładowanie...",
"lastScans": "Ostatnie skany:",
"error": "Wystąpił błąd",
"closeError": "Zamknij."
}

}
13 changes: 3 additions & 10 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,15 @@ class _PolaAppState extends State<PolaApp> {
body: IndexedStack(
index: _selectedIndex,
children: _tabs,
)
),
)),
),
);
}

final List<Widget> _tabs = [
MainPage(),
WebViewTab(
title: "Wyszukiwarka",
url: "https://www.pola-app.pl/m/search/"
),
WebViewTab(
title: "Wiadomości",
url: "https://www.pola-app.pl/m/blog/"
)
WebViewTab(title: "Wyszukiwarka", url: "https://www.pola-app.pl/m/search/"),
WebViewTab(title: "Wiadomości", url: "https://www.pola-app.pl/m/blog/")
];

AnalyticsMainTab _getTabParameter(int index) {
Expand Down
96 changes: 70 additions & 26 deletions lib/pages/scan/companies_list.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import 'package:flutter/material.dart';
import 'package:pola_flutter/analytics/pola_analytics.dart';
import 'package:pola_flutter/i18n/strings.g.dart';
import 'package:pola_flutter/pages/scan/remote_button.dart';
import 'package:pola_flutter/pages/scan/scan_state.dart';
import 'package:pola_flutter/theme/text_size.dart';
import 'package:pola_flutter/ui/list_item.dart';
import 'dart:math';

class CompaniesList extends StatelessWidget {
CompaniesList(this.state, this.listScrollController);
Expand All @@ -13,35 +16,48 @@ class CompaniesList extends StatelessWidget {

@override
Widget build(BuildContext context) {
final int listSize = state.list.length;

_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);
},
);
},

double maxHeight = min(listSize * 47.5, 190.0);

return Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
_ListHeader(listSize: listSize),
Container(
constraints: BoxConstraints(
maxHeight: maxHeight,
),
child: Align(
alignment: Alignment.bottomCenter,
child: ListView.builder(
controller: listScrollController,
reverse: true,
itemCount: listSize + (state.isLoading ? 1 : 0),
itemBuilder: (BuildContext context, int index) {
if (index == listSize) {
return LoadingListItem();
}
return GestureDetector(
child: ResultListItem(state.list[index]),
onTap: () {
final result = state.list[index];
_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 @@ -53,3 +69,31 @@ class CompaniesList extends StatelessWidget {
});
}
}

class _ListHeader extends StatelessWidget {
final int listSize;

const _ListHeader({required this.listSize});

@override
Widget build(BuildContext context) {
if (listSize > 0) {
return Padding(
padding: const EdgeInsets.only(left: 16.0),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
t.scan.lastScans,
style: TextStyle(
fontSize: TextSize.mediumTitle,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
),
);
} else {
return Container();
}
}
}
Loading
Loading