Compare commits

..

2 Commits

Author SHA1 Message Date
c0c3ef2ca0 Fix: shorten name 2024-06-09 14:40:30 +03:00
9335e8e694 fix: some fixes 2024-06-09 12:47:59 +03:00
9 changed files with 84 additions and 87 deletions

View File

@@ -22,6 +22,11 @@ class GymLinkAppBar extends StatelessWidget implements PreferredSizeWidget {
width: 24, width: 24,
height: 24, height: 24,
semanticsLabel: 'GymLink Logo', semanticsLabel: 'GymLink Logo',
colorFilter: ColorFilter.mode(
Theme.of(context).brightness == Brightness.dark
? Colors.white
: Colors.black,
BlendMode.srcIn),
), ),
), ),
Align( Align(

View File

@@ -129,7 +129,7 @@ class _ExamplePageState extends State<ExamplePage> {
Future<void> _setToken() async { Future<void> _setToken() async {
final token = await getToken('eeb42dcb-8e5b-4f21-825a-3fc7ada43445', '123'); final token = await getToken('eeb42dcb-8e5b-4f21-825a-3fc7ada43445', '123');
if (token != '') { if (token != '') {
context.read<GymLinkProvider>().onTokenReceived(token); context.read<GymLinkProvider>().checkToken(token);
} else { } else {
context.read<GymLinkProvider>().onError(); context.read<GymLinkProvider>().onError();
} }
@@ -205,7 +205,7 @@ class _ExampleClub2PageState extends State<ExampleClub2Page> {
final token = await getToken('a8622a61-3142-487e-8db8-b6aebd4f04aa', '123'); final token = await getToken('a8622a61-3142-487e-8db8-b6aebd4f04aa', '123');
context.read<GymLinkProvider>().changeTheme(0xFFAABCAB); context.read<GymLinkProvider>().changeTheme(0xFFAABCAB);
if (token != '') { if (token != '') {
context.read<GymLinkProvider>().onTokenReceived(token); context.read<GymLinkProvider>().checkToken(token);
} else { } else {
context.read<GymLinkProvider>().onError(); context.read<GymLinkProvider>().onError();
} }

View File

@@ -9,6 +9,7 @@ import 'package:gymlink_module_web/providers/cart.dart';
import 'package:gymlink_module_web/tools/items.dart'; import 'package:gymlink_module_web/tools/items.dart';
import 'package:gymlink_module_web/tools/prefs.dart'; import 'package:gymlink_module_web/tools/prefs.dart';
import 'package:gymlink_module_web/tools/routes.dart'; import 'package:gymlink_module_web/tools/routes.dart';
import 'package:gymlink_module_web/tools/text.dart';
import 'package:lazy_load_scrollview/lazy_load_scrollview.dart'; import 'package:lazy_load_scrollview/lazy_load_scrollview.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@@ -279,7 +280,7 @@ class _BasketPageState extends State<BasketPage> {
itemBuilder: (context, index) { itemBuilder: (context, index) {
final item = cartItems[index]; final item = cartItems[index];
return BasketItemCard( return BasketItemCard(
name: item.title, name: shortString(item.title),
price: item.price.toStringAsFixed(2), price: item.price.toStringAsFixed(2),
id: item.id, id: item.id,
image: Image( image: Image(

View File

@@ -73,6 +73,7 @@ class _MainPageState extends State<MainPage> {
bool isSearching = false; bool isSearching = false;
List<GymCategory> categories = []; List<GymCategory> categories = [];
GymCategory? selectedCategory; GymCategory? selectedCategory;
final ScrollController _scrollController = ScrollController();
@override @override
void initState() { void initState() {
@@ -122,7 +123,7 @@ class _MainPageState extends State<MainPage> {
}); });
} }
void _onSearch() async { void _onSearch() {
final categoryId = selectedCategory == null ? '' : selectedCategory!.id; final categoryId = selectedCategory == null ? '' : selectedCategory!.id;
_searchItems(searchText: searchText, categoryId: categoryId); _searchItems(searchText: searchText, categoryId: categoryId);
} }
@@ -250,7 +251,9 @@ class _MainPageState extends State<MainPage> {
onEndOfPage: _onLoad, onEndOfPage: _onLoad,
isLoading: isLoading, isLoading: isLoading,
child: Scrollbar( child: Scrollbar(
controller: _scrollController,
child: ListView( child: ListView(
controller: _scrollController,
children: [ children: [
filteredData.isEmpty && filteredData.isEmpty &&
(searchText != '' || selectedCategory != null) && (searchText != '' || selectedCategory != null) &&

View File

@@ -9,6 +9,7 @@ import 'package:gymlink_module_web/providers/cart.dart';
import 'package:gymlink_module_web/tools/items.dart'; import 'package:gymlink_module_web/tools/items.dart';
import 'package:gymlink_module_web/tools/prefs.dart'; import 'package:gymlink_module_web/tools/prefs.dart';
import 'package:gymlink_module_web/tools/routes.dart'; import 'package:gymlink_module_web/tools/routes.dart';
import 'package:gymlink_module_web/tools/text.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
@@ -113,7 +114,7 @@ class _OrderConfirmationPageState extends State<OrderConfirmationPage> {
itemBuilder: (context, index) { itemBuilder: (context, index) {
final item = cartItems[index]; final item = cartItems[index];
return OrderConfirmItemCard( return OrderConfirmItemCard(
name: item.title, name: shortString(item.title),
image: Image( image: Image(
image: NetworkImage(item.images[0].url), image: NetworkImage(item.images[0].url),
width: 50, width: 50,

View File

@@ -14,17 +14,10 @@ class GymLinkProvider with ChangeNotifier {
void Function() get onError => _onError; void Function() get onError => _onError;
void onTokenReceived(String token) { void checkToken(String token) {
_token = token; _token = token;
_isLoading = false; _isLoading = false;
notifyListeners(); notifyListeners();
// if (token == 'token123') {
// _isLoading = false;
// notifyListeners();
// } else {
// _isLoading = true;
// notifyListeners();
// }
} }
void changeTheme(int color, {bool blackTheme = false}) { void changeTheme(int color, {bool blackTheme = false}) {

View File

@@ -48,13 +48,13 @@ class MyAppStateWeb extends State<MyApp> {
} }
@js.JSExport() @js.JSExport()
void onTokenReceived(String token) { void checkToken(String token) {
context.read<GymLinkProvider>().onTokenReceived(token); context.read<GymLinkProvider>().checkToken(token);
} }
@js.JSExport() @js.JSExport()
void changeColor(int color) { void changeColor(int color, bool blackTheme) {
context.read<GymLinkProvider>().changeTheme(color); context.read<GymLinkProvider>().changeTheme(color, blackTheme: blackTheme);
} }
@js.JSExport() @js.JSExport()

View File

@@ -1,6 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<!-- <!--
If you are serving your web app in a path other than the root, change the If you are serving your web app in a path other than the root, change the
href value below to reflect the base path you are serving from. href value below to reflect the base path you are serving from.
@@ -14,24 +14,24 @@
This is a placeholder for base href that will be replaced by the value of This is a placeholder for base href that will be replaced by the value of
the `--base-href` argument provided to `flutter build`. the `--base-href` argument provided to `flutter build`.
--> -->
<base href="$FLUTTER_BASE_HREF"> <base href="$FLUTTER_BASE_HREF" />
<meta charset="UTF-8"> <meta charset="UTF-8" />
<meta content="IE=Edge" http-equiv="X-UA-Compatible"> <meta content="IE=Edge" http-equiv="X-UA-Compatible" />
<meta name="description" content="A new Flutter project."> <meta name="description" content="A new Flutter project." />
<!-- iOS meta tags & icons --> <!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black"> <meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="apple-mobile-web-app-title" content="flutter_application_1"> <meta name="apple-mobile-web-app-title" content="flutter_application_1" />
<link rel="apple-touch-icon" href="icons/Icon-192.png"> <link rel="apple-touch-icon" href="icons/Icon-192.png" />
<!-- Favicon --> <!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png"/> <link rel="icon" type="image/png" href="favicon.png" />
<title>flutter_application_1</title> <title>flutter_application_1</title>
<link rel='stylesheet' href='css/styles.css'> <link rel="stylesheet" href="css/styles.css" />
<link rel="manifest" href="manifest.json"> <link rel="manifest" href="manifest.json" />
<!-- <script> <!-- <script>
// The value below is injected by flutter build, do not touch. // The value below is injected by flutter build, do not touch.
@@ -39,18 +39,19 @@
</script> --> </script> -->
<!-- This script adds the flutter initialization JS code --> <!-- This script adds the flutter initialization JS code -->
<script src="flutter.js" defer></script> <script src="flutter.js" defer></script>
</head> </head>
<body> <body>
<button id='token'>Token btn</button> <button id="token">Token btn</button>
<button id='colorChangeBtnRed'>Color btn Red</button> <button id="token2">Token btn 2</button>
<button id='colorChangeBtnBlue'>Color btn Blue</button> <button id="colorChangeBtnRed">Color btn Red</button>
<section class='contents'> <button id="colorChangeBtnBlue">Color btn Blue</button>
<section class="contents">
<article> <article>
<div id="flutter_target"></div> <div id="flutter_target"></div>
</article> </article>
</section> </section>
<script> <script>
window.addEventListener('load', function(ev) { window.addEventListener('load', function (ev) {
let target = document.querySelector('#flutter_target'); let target = document.querySelector('#flutter_target');
_flutter.loader.loadEntrypoint({ _flutter.loader.loadEntrypoint({
onEntrypointLoaded: async function (engineInitializer) { onEntrypointLoaded: async function (engineInitializer) {
@@ -58,10 +59,10 @@
hostElement: target, hostElement: target,
}); });
await appRunner.runApp(); await appRunner.runApp();
} },
}) });
}); });
</script> </script>
<script src='js/demo-js-interop.js' defer></script> <script src="js/demo-js-interop.js" defer></script>
</body> </body>
</html> </html>

View File

@@ -7,26 +7,22 @@
}; };
let appState = window._appState; let appState = window._appState;
function getToken() { function getToken(token) {
fetch( fetch('http://gymlink.freemyip.com:8080/api/auth/authorize_client', {
'http://gymlink.freemyip.com:8080/api/auth/authorize_client',
{
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ body: JSON.stringify({
GymKey: 'eeb42dcb-8e5b-4f21-825a-3fc7ada43445', // Just testing token GymKey: token, // Just testing token
id: '123', id: '123',
}), }),
} })
)
.then(res => res.json()) .then(res => res.json())
.catch(e => { .catch(e => {
console.log(e); console.log(e);
setTimeout(getToken, 1000); setTimeout(getToken, 1000);
}) })
.then(data => { .then(data => {
if (data.payload) if (data.payload) appState.checkToken(data.payload.token);
appState.onTokenReceived(data.payload.token);
else { else {
console.log(data); console.log(data);
setTimeout(getToken, 1000); setTimeout(getToken, 1000);
@@ -34,31 +30,28 @@
}); });
} }
let btn = document.getElementById('token'); const btn = document.getElementById('token');
btn.addEventListener('click', getToken); btn.addEventListener('click', () => getToken('eeb42dcb-8e5b-4f21-825a-3fc7ada43445'));
const btn2 = document.getElementById('token2');
btn2.addEventListener('click', () => getToken('a8622a61-3142-487e-8db8-b6aebd4f04aa'));
let colorChangeBtnRed = document.getElementById('colorChangeBtnRed'); let colorChangeBtnRed = document.getElementById('colorChangeBtnRed');
colorChangeBtnRed.addEventListener('click', function () { colorChangeBtnRed.addEventListener('click', function () {
var hexColor = '#FF0000' var hexColor = '#FF0000'
.replace( .replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, (m, r, g, b) => '#ff' + r + r + g + g + b + b)
/^#?([a-f\d])([a-f\d])([a-f\d])$/i,
(m, r, g, b) => '#ff' + r + r + g + g + b + b
)
.substring(1); .substring(1);
var numColor = parseInt(hexColor, 16); var numColor = parseInt(hexColor, 16);
appState.changeColor(numColor); appState.changeColor(numColor, true);
}); });
let colorChangeBtnBlue = document.getElementById('colorChangeBtnBlue'); let colorChangeBtnBlue = document.getElementById('colorChangeBtnBlue');
colorChangeBtnBlue.addEventListener('click', function () { colorChangeBtnBlue.addEventListener('click', function () {
var hexColor = '#0000FF' var hexColor = '#0000FF'
.replace( .replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, (m, r, g, b) => '#ff' + r + r + g + g + b + b)
/^#?([a-f\d])([a-f\d])([a-f\d])$/i,
(m, r, g, b) => '#ff' + r + r + g + g + b + b
)
.substring(1); .substring(1);
var numColor = parseInt(hexColor, 16); var numColor = parseInt(hexColor, 16);
appState.changeColor(numColor); appState.changeColor(numColor, false);
}); });
function onError() { function onError() {