Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

Commit

Permalink
fix: Improve spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
Myzel394 committed Sep 26, 2023
1 parent 0938858 commit 1827ff0
Showing 1 changed file with 99 additions and 105 deletions.
204 changes: 99 additions & 105 deletions lib/screens/locations_overview_screen_widgets/ViewDetailsSheet.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
import 'package:latlong2/latlong.dart';
import 'package:locus/screens/locations_overview_screen_widgets/ViewDetails.dart';
import 'package:locus/services/location_point_service.dart';
import 'package:locus/services/view_service/index.dart';
Expand Down Expand Up @@ -32,17 +31,16 @@ class _ViewDetailsSheetState extends State<ViewDetailsSheet> {
final containerKey = GlobalKey();

final DraggableScrollableController controller =
DraggableScrollableController();
DraggableScrollableController();

// Index starting from last element
int locationIndex = 0;
TaskView? oldView;
bool isExpanded = false;

LocationPointService? get currentLocation =>
widget.locations == null
? null
: widget.locations![widget.locations!.length - 1 - locationIndex];
LocationPointService? get currentLocation => widget.locations == null
? null
: widget.locations![widget.locations!.length - 1 - locationIndex];

@override
void initState() {
Expand Down Expand Up @@ -113,110 +111,106 @@ class _ViewDetailsSheetState extends State<ViewDetailsSheet> {
0.22,
1,
],
builder: (context, scrollController) =>
ModalSheet(
miuiIsGapless: true,
materialPadding: EdgeInsets.zero,
cupertinoPadding: EdgeInsets.zero,
sheetController: controller,
child: SingleChildScrollView(
controller: scrollController,
child: Column(
children: [
const SizedBox(height: MEDIUM_SPACE),
if (view != null)
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Icon(
Icons.circle_rounded,
size: 20,
color: view.color,
),
const SizedBox(width: SMALL_SPACE),
Text(view.name),
],
builder: (context, scrollController) => ModalSheet(
miuiIsGapless: true,
materialPadding: EdgeInsets.zero,
cupertinoPadding: EdgeInsets.zero,
sheetController: controller,
child: SingleChildScrollView(
controller: scrollController,
child: Column(
children: [
const SizedBox(height: MEDIUM_SPACE),
if (view != null)
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Icon(
Icons.circle_rounded,
size: 20,
color: view.color,
),
if (widget.locations != null &&
widget.locations!.isNotEmpty) ...[
const SizedBox(height: MEDIUM_SPACE),
SizedBox(
height: 120,
child: PageView.builder(
physics: null,
onPageChanged: (index) {
final location = widget.locations![index];

widget.onVisibleLocationChange(location);

if (!isExpanded) {
widget.onGoToPosition(location);
}

setState(() {
locationIndex = index;
});
},
reverse: true,
itemCount: widget.locations!.length,
itemBuilder: (context, index) =>
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(
MEDIUM_SPACE),
color: platformThemeData(
context,
material: (data) =>
data.colorScheme.surfaceVariant,
cupertino: (data) => data.barBackgroundColor,
),
),
margin:
const EdgeInsets.symmetric(
horizontal: MEDIUM_SPACE),
padding: const EdgeInsets.all(MEDIUM_SPACE),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
const Icon(Icons.drag_indicator_rounded),
const SizedBox(width: SMALL_SPACE),
Flexible(
child: SimpleAddressFetcher(
location: widget.locations![index]
.asLatLng(),
),
),
],
),
),
const SizedBox(width: SMALL_SPACE),
Text(view.name),
],
),
if (widget.locations != null && widget.locations!.isNotEmpty) ...[
const SizedBox(height: MEDIUM_SPACE),
SizedBox(
height: 120,
child: PageView.builder(
physics: null,
onPageChanged: (index) {
final location = widget.locations![index];

widget.onVisibleLocationChange(location);

if (!isExpanded) {
widget.onGoToPosition(location);
}

setState(() {
locationIndex = index;
});
},
reverse: true,
itemCount: widget.locations!.length,
itemBuilder: (context, index) => Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(MEDIUM_SPACE),
color: platformThemeData(
context,
material: (data) => data.colorScheme.surfaceVariant,
cupertino: (data) => data.barBackgroundColor,
),
),
),
const SizedBox(width: MEDIUM_SPACE),
Padding(
margin:
const EdgeInsets.symmetric(horizontal: MEDIUM_SPACE),
padding: const EdgeInsets.all(MEDIUM_SPACE),
child: ViewDetails(
location: currentLocation,
view: widget.view,
onGoToPosition: (position) {
controller.animateTo(
0.22,
duration: const Duration(milliseconds: 150),
curve: Curves.fastLinearToSlowEaseIn,
);
widget.onGoToPosition(position);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
const Icon(Icons.drag_indicator_rounded),
const SizedBox(width: SMALL_SPACE),
Flexible(
child: SimpleAddressFetcher(
location: widget.locations![index].asLatLng(),
),
),
],
),
)
] else
Text(
l10n.locationFetchEmptyError,
)
],
),
),
),
),
),
const SizedBox(width: MEDIUM_SPACE),
Padding(
padding: const EdgeInsets.all(MEDIUM_SPACE),
child: ViewDetails(
location: currentLocation,
view: widget.view,
onGoToPosition: (position) {
controller.animateTo(
0.22,
duration: const Duration(milliseconds: 150),
curve: Curves.fastLinearToSlowEaseIn,
);
widget.onGoToPosition(position);
},
),
)
] else
Padding(
padding: const EdgeInsets.all(MEDIUM_SPACE),
child: Text(
l10n.locationFetchEmptyError,
),
)
],
),
),
),
);
}
}

0 comments on commit 1827ff0

Please sign in to comment.