mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 13:08:42 +00:00
fix #57
This commit is contained in:
parent
241662a9d3
commit
9ec9b7a772
3 changed files with 69 additions and 31 deletions
|
|
@ -38,9 +38,11 @@ class FilterSceleton extends StatelessWidget {
|
|||
}
|
||||
|
||||
class FilterText extends StatelessWidget {
|
||||
const FilterText(this.text, {super.key, this.fontSize = 24});
|
||||
const FilterText(this.text,
|
||||
{super.key, this.fontSize = 24, this.color = Colors.white});
|
||||
final String text;
|
||||
final double fontSize;
|
||||
final Color color;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
@ -49,7 +51,7 @@ class FilterText extends StatelessWidget {
|
|||
textAlign: TextAlign.start,
|
||||
style: TextStyle(
|
||||
fontSize: fontSize,
|
||||
color: Colors.white,
|
||||
color: color,
|
||||
shadows: [
|
||||
Shadow(
|
||||
color: const Color.fromARGB(122, 0, 0, 0),
|
||||
|
|
@ -62,20 +64,51 @@ class FilterText extends StatelessWidget {
|
|||
}
|
||||
|
||||
class _FilterLayerState extends State<FilterLayer> {
|
||||
final PageController pageController = PageController();
|
||||
final List<Widget> pages = [
|
||||
FilterSceleton(),
|
||||
DateTimeFilter(),
|
||||
LocationFilter(),
|
||||
ImageFilter(imagePath: "random/lol.png"),
|
||||
ImageFilter(imagePath: "random/hide_the_pain.png"),
|
||||
ImageFilter(imagePath: "random/yolo.png"),
|
||||
ImageFilter(imagePath: "random/chillen.png"),
|
||||
ImageFilter(imagePath: "random/avocardio.png"),
|
||||
ImageFilter(imagePath: "random/duck.png"),
|
||||
FilterSceleton(),
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
pageController.jumpToPage(1);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PageView(
|
||||
children: [
|
||||
FilterSceleton(),
|
||||
DateTimeFilter(),
|
||||
LocationFilter(),
|
||||
ImageFilter(imagePath: "random/lol.png"),
|
||||
ImageFilter(imagePath: "random/hide_the_pain.png"),
|
||||
ImageFilter(imagePath: "random/yolo.png"),
|
||||
ImageFilter(imagePath: "random/chillen.png"),
|
||||
ImageFilter(imagePath: "random/avocardio.png"),
|
||||
ImageFilter(imagePath: "random/duck.png"),
|
||||
],
|
||||
return PageView.builder(
|
||||
controller: pageController,
|
||||
itemCount: pages.length + 2, // Add two for the duplicated pages
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0) {
|
||||
return pages.last; // Show the last page
|
||||
} else if (index == pages.length + 1) {
|
||||
return pages.first; // Show the first page
|
||||
} else {
|
||||
return pages[index - 1]; // Show the actual pages
|
||||
}
|
||||
},
|
||||
onPageChanged: (index) {
|
||||
if (index == 0) {
|
||||
// If the user swipes to the first duplicated page, jump to the last page
|
||||
pageController.jumpToPage(pages.length);
|
||||
} else if (index == pages.length + 1) {
|
||||
// If the user swipes to the last duplicated page, jump to the first page
|
||||
pageController.jumpToPage(1);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@ import 'package:intl/intl.dart';
|
|||
import 'package:twonly/src/components/image_editor/layers/filter_layer.dart';
|
||||
|
||||
class DateTimeFilter extends StatelessWidget {
|
||||
const DateTimeFilter({super.key});
|
||||
const DateTimeFilter({super.key, this.color = Colors.white});
|
||||
|
||||
final Color color;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
@ -16,8 +18,8 @@ class DateTimeFilter extends StatelessWidget {
|
|||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
FilterText(currentTime),
|
||||
FilterText(currentDate),
|
||||
FilterText(currentTime, color: color),
|
||||
FilterText(currentDate, color: color),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:twonly/globals.dart';
|
||||
import 'package:twonly/src/components/image_editor/layers/filter_layer.dart';
|
||||
import 'package:twonly/src/components/image_editor/layers/filters/datetime_filter.dart';
|
||||
import 'package:twonly/src/components/image_editor/layers/filters/image_filter.dart';
|
||||
import 'package:twonly/src/proto/api/server_to_client.pb.dart';
|
||||
|
||||
|
|
@ -66,22 +67,24 @@ class _LocationFilterState extends State<LocationFilter> {
|
|||
}
|
||||
|
||||
if (location != null) {
|
||||
return FilterSceleton(
|
||||
child: Positioned(
|
||||
bottom: 50,
|
||||
left: 40,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
FilterText(location!.city),
|
||||
FilterText(location!.region),
|
||||
FilterText(location!.county),
|
||||
],
|
||||
if (location!.county != "-") {
|
||||
return FilterSceleton(
|
||||
child: Positioned(
|
||||
bottom: 50,
|
||||
left: 40,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
FilterText(location!.city),
|
||||
FilterText(location!.region),
|
||||
FilterText(location!.county),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return Container();
|
||||
return DateTimeFilter(color: Colors.black);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue