openstore/lib/main.dart

99 lines
2.9 KiB
Dart
Raw Normal View History

2024-08-06 19:06:38 +03:00
import 'package:flutter/material.dart';
2025-04-27 18:17:40 +03:00
import 'package:openstore/app_page.dart';
2024-08-06 19:06:38 +03:00
import 'package:openstore/search_page.dart';
2025-04-27 18:17:40 +03:00
import 'package:go_router/go_router.dart';
import 'package:dynamic_color/dynamic_color.dart';
2024-08-06 19:06:38 +03:00
void main() {
runApp(const MyApp());
}
2025-04-27 18:17:40 +03:00
final _router = GoRouter(
routes: [
GoRoute(path: '/', builder: (context, state) => const HomePage(), routes: [
GoRoute(
path: '/app/:id',
builder: (context, state) =>
AppPage(packageName: state.pathParameters['id'] ?? ""),
),
GoRoute(
path: 'instruction',
builder: (context, state) {
print(state.uri.queryParameters["utm_campaign"]);
return AppPage(packageName: "ru.nspk.mirpay");
})
]),
GoRoute(
path: '/search',
builder: (context, state) =>
SearchPage(search: state.uri.queryParameters["q"] ?? "")),
GoRoute(
path: '/catalog/app/:id',
redirect: (_, state) => "/app/${state.pathParameters["id"]}"),
],
);
2024-08-06 19:06:38 +03:00
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return DynamicColorBuilder(
builder: (lightColorScheme, darkColorScheme) => MaterialApp.router(
title: 'OpenStore',
theme: ThemeData(
pageTransitionsTheme: const PageTransitionsTheme(builders: {
TargetPlatform.android:
PredictiveBackPageTransitionsBuilder(),
}),
colorScheme: darkColorScheme ??
ColorScheme.fromSeed(
seedColor: Colors.blue,
brightness: Brightness.dark,
),
useMaterial3: true,
),
routerConfig: _router,
));
2024-08-06 19:06:38 +03:00
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("OpenStore"),
),
body: Center(
child: Row(
children: [
2025-04-27 18:17:40 +03:00
const SizedBox(
width: 15,
),
2024-08-06 19:06:38 +03:00
Flexible(
child: TextField(
2025-04-27 18:17:40 +03:00
onSubmitted: (value) => context.push(
Uri(path: '/search', queryParameters: {'q': value})
.toString()),
2024-08-06 19:06:38 +03:00
textInputAction: TextInputAction.search,
decoration: InputDecoration(
2025-04-27 18:17:40 +03:00
prefixIcon: Icon(Icons.search),
border: OutlineInputBorder()),
2024-08-06 19:06:38 +03:00
),
),
//const SizedBox(width: 5,),
//FilledButton(onPressed: (){}, child: Text("GO")),
2025-04-27 18:17:40 +03:00
const SizedBox(
width: 15,
),
2024-08-06 19:06:38 +03:00
],
),
),
);
}
2025-04-27 18:17:40 +03:00
}