Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

Commit

Permalink
style: fixing some lint issues
Browse files Browse the repository at this point in the history
- apply lint
- add const when needed
- fix misspelling issue
- remove unnecessary `new` keyword
  • Loading branch information
Thithip committed Mar 29, 2024
1 parent 632782c commit 22a6f9f
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 185 deletions.
31 changes: 14 additions & 17 deletions lib/component/collection_preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ class CollectionPreview extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.all(10),
margin: const EdgeInsets.all(10),
height: 230,
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(
borderRadius: const BorderRadius.all(
Radius.circular(18),
),
boxShadow: [
BoxShadow(
color: Colors.grey.shade200,
spreadRadius: 4,
blurRadius: 6,
offset: Offset(0, 3),
offset: const Offset(0, 3),
),
],
),
Expand All @@ -29,7 +29,7 @@ class CollectionPreview extends StatelessWidget {
Container(
height: 140,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(18),
topRight: Radius.circular(18),
),
Expand All @@ -45,9 +45,9 @@ class CollectionPreview extends StatelessWidget {
right: -15,
child: MaterialButton(
color: Colors.white,
shape: CircleBorder(),
shape: const CircleBorder(),
onPressed: () {},
child: Icon(
child: const Icon(
Icons.edit_rounded,
size: 20,
),
Expand All @@ -57,7 +57,7 @@ class CollectionPreview extends StatelessWidget {
),
),
Container(
margin: EdgeInsets.fromLTRB(10, 10, 10, 0),
margin: const EdgeInsets.fromLTRB(10, 10, 10, 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expand All @@ -72,7 +72,7 @@ class CollectionPreview extends StatelessWidget {
),
),
Container(
margin: EdgeInsets.symmetric(horizontal: 10),
margin: const EdgeInsets.symmetric(horizontal: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expand All @@ -88,28 +88,25 @@ class CollectionPreview extends StatelessWidget {
),
),
Container(
margin: EdgeInsets.fromLTRB(10, 3, 10, 0),
margin: const EdgeInsets.fromLTRB(10, 3, 10, 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
DateFormat(DATE_FORMATTER).format(DateTime.parse(
collection.updated != null ?
collection.updated! :
collection.created
)),
collection.updated != null
? collection.updated!
: collection.created)),
style: GoogleFonts.nunito(
fontSize: 14,
color: Colors.grey[500],
fontWeight: FontWeight.w400,
)
)
))
],
),
),
],
),
);
}

}
}
5 changes: 2 additions & 3 deletions lib/component/loader.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:loading_animation_widget/loading_animation_widget.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import '../constant.dart';

class Loader extends StatelessWidget {
Expand All @@ -16,8 +15,8 @@ class Loader extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
color: this.shadowBackground ?
Color.fromRGBO(0, 0, 0, 50) :
color: shadowBackground ?
const Color.fromRGBO(0, 0, 0, 50) :
Colors.transparent
,
child: Column(
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ part 'service/routing.dart';
part 'service/permission_helper.dart';


final String DATE_FORMATTER = 'dd/MM/y HH:mm:ss';
const String DATE_FORMATTER = 'dd/MM/y HH:mm:ss';

void main() {
runApp(const PanoramaxApp());
Expand Down
201 changes: 98 additions & 103 deletions lib/page/capture_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class _CapturePageState extends State<CapturePage> {
super.initState();

if (widget.cameras?.isNotEmpty ?? false) {
initCamera(widget.cameras![0]);
initCamera(widget.cameras![0]);
}
}

void goToCollectionCreationPage(){
void goToCollectionCreationPage() {
context.push(Routes.newSequenceSend, extra: _imgListCaptured);
}

Expand All @@ -46,10 +46,12 @@ class _CapturePageState extends State<CapturePage> {
}
try {
if (await PermissionHelper.isPermissionGranted()) {
await Future.wait([
getPictureFromCamera(),
Geolocator.getCurrentPosition()
]).then((value) async {
await Future.wait(
[
getPictureFromCamera(),
Geolocator.getCurrentPosition(),
],
).then((value) async {
final XFile rawImage = value[0] as XFile;
final Position currentLocation = value[1] as Position;
await addExifTags(rawImage, currentLocation);
Expand Down Expand Up @@ -87,8 +89,11 @@ class _CapturePageState extends State<CapturePage> {
}

Future initCamera(CameraDescription cameraDescription) async {
_cameraController =
CameraController(cameraDescription, ResolutionPreset.high, enableAudio: false);
_cameraController = CameraController(
cameraDescription,
ResolutionPreset.high,
enableAudio: false,
);
try {
await _cameraController.initialize().then((_) {
if (!mounted) return;
Expand All @@ -112,131 +117,121 @@ class _CapturePageState extends State<CapturePage> {
}
var height = MediaQuery.of(context).size.height * 0.12;
var cartIcon = IconButton(
onPressed: () {
},
onPressed: () {},
iconSize: 30,
padding: EdgeInsets.zero,
constraints: const BoxConstraints(),
icon: const Icon(Icons.add_shopping_cart_outlined, color: Colors.white),
);
return Stack(
children: [
cameraPreview(),
captureButton(height, context),
Positioned(
bottom: 0,
left: 0,
child: Container(
width: MediaQuery.of(context).size.width,
height: height,
decoration: const BoxDecoration(color: Colors.black),
child: Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
switchCameraButton(context),
imageCart(cartIcon),
createSequenceButton(context),
]),
)
children: [
cameraPreview(),
captureButton(height, context),
Positioned(
bottom: 0,
left: 0,
child: Container(
width: MediaQuery.of(context).size.width,
height: height,
decoration: const BoxDecoration(color: Colors.black),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
switchCameraButton(context),
imageCart(cartIcon),
createSequenceButton(context),
],
),
if(_isProcessing) processingLoader(context)
]
);
),
),
if (_isProcessing) processingLoader(context)
],
);
}

Expanded switchCameraButton(BuildContext context) {
return Expanded(
child: IconButton(
padding: EdgeInsets.zero,
iconSize: 30,
icon: Icon(
_isRearCameraSelected
? CupertinoIcons.switch_camera
: CupertinoIcons.switch_camera_solid,
color: Colors.white),
onPressed: () {
setState(
() => _isRearCameraSelected = !_isRearCameraSelected);
initCamera(widget.cameras![_isRearCameraSelected ? 0 : 1]);
},
tooltip: AppLocalizations.of(context)!.switchCamera
)
);
child: IconButton(
padding: EdgeInsets.zero,
iconSize: 30,
icon: Icon(_isRearCameraSelected ? CupertinoIcons.switch_camera : CupertinoIcons.switch_camera_solid,
color: Colors.white),
onPressed: () {
setState(() => _isRearCameraSelected = !_isRearCameraSelected);
initCamera(widget.cameras![_isRearCameraSelected ? 0 : 1]);
},
tooltip: AppLocalizations.of(context)!.switchCamera),
);
}

Expanded createSequenceButton(BuildContext context) {
return Expanded(
child: IconButton(
padding: EdgeInsets.zero,
iconSize: 30,
icon: const Icon(
Icons.send_outlined,
color: Colors.white
),
onPressed: goToCollectionCreationPage,
tooltip: AppLocalizations.of(context)!.createSequenceWithPicture_tooltip
)
);
child: IconButton(
padding: EdgeInsets.zero,
iconSize: 30,
icon: const Icon(Icons.send_outlined, color: Colors.white),
onPressed: goToCollectionCreationPage,
tooltip: AppLocalizations.of(context)!.createSequenceWithPicture_tooltip));
}

Widget imageCart(IconButton cartIcon) {
return _imgListCaptured.isNotEmpty ?
badges.Badge(
badgeContent: Text('${_imgListCaptured.length}'),
child: cartIcon,
):
cartIcon;
return _imgListCaptured.isNotEmpty
? badges.Badge(
badgeContent: Text('${_imgListCaptured.length}'),
child: cartIcon,
)
: cartIcon;
}

Positioned captureButton(double height, BuildContext context) {
return Positioned(
bottom: height,
left: 0,
child: Container(
width: MediaQuery.of(context).size.width,
height: height,
decoration: const BoxDecoration(color: Colors.transparent),
child: Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
Expanded(
child: IconButton(
onPressed: takePicture,
iconSize: 100,
padding: EdgeInsets.zero,
constraints: const BoxConstraints(),
icon: const Icon(Icons.circle_outlined, color: Colors.white),
tooltip: AppLocalizations.of(context)!.capture
)),
]),
)
);
bottom: height,
left: 0,
child: Container(
width: MediaQuery.of(context).size.width,
height: height,
decoration: const BoxDecoration(color: Colors.transparent),
child: Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
Expanded(
child: IconButton(
onPressed: takePicture,
iconSize: 100,
padding: EdgeInsets.zero,
constraints: const BoxConstraints(),
icon: const Icon(Icons.circle_outlined, color: Colors.white),
tooltip: AppLocalizations.of(context)!.capture),
),
]),
));
}

StatelessWidget cameraPreview() {
return _cameraController.value.isInitialized
? CameraPreview(_cameraController)
: Container(
color: Colors.transparent,
child: const Center(child: CircularProgressIndicator()
)
);
? CameraPreview(_cameraController)
: Container(
color: Colors.transparent,
child: const Center(child: CircularProgressIndicator()),
);
}

Positioned processingLoader(BuildContext context) {
return Positioned(
top: 0,
bottom: 0,
left: 0,
right: 0,
child: Loader(
message: DefaultTextStyle(
style: Theme.of(context).textTheme.bodyLarge!,
child: Text(
AppLocalizations.of(context)!.waitDuringProcessing,
style: const TextStyle(
color: Colors.white,
),
),
top: 0,
bottom: 0,
left: 0,
right: 0,
child: Loader(
message: DefaultTextStyle(
style: Theme.of(context).textTheme.bodyLarge!,
child: Text(
AppLocalizations.of(context)!.waitDuringProcessing,
style: const TextStyle(
color: Colors.white,
),
shadowBackground: true
)
),
),
shadowBackground: true,
),
);
}
}
}
Loading

0 comments on commit 22a6f9f

Please sign in to comment.