Skip to content

Commit

Permalink
- use Zeta radii
Browse files Browse the repository at this point in the history
- add missing docs
- fix color tokens
  • Loading branch information
ps9310 committed Oct 14, 2024
1 parent e099b76 commit 9f5e072
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 99 deletions.
61 changes: 0 additions & 61 deletions lib/src/components/molecules/date_range_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -608,67 +608,6 @@ class _DatePickerHeader extends StatelessWidget {
}
}

/// Use [showZdsDateRangePicker]
@Deprecated('Use showZdsDateRangePicker')
Future<DateTimeRange?> showRflxDateRangePicker({
required DateTime firstDate,
required DateTime lastDate,
required BuildContext context,
DateTimeRange? initialDateRange,
DateTime? currentDate,
DatePickerEntryMode initialEntryMode = DatePickerEntryMode.calendar,
String? helpText,
String? cancelText,
String? confirmText,
String? saveText,
String? errorFormatText,
String? errorInvalidText,
String? errorInvalidRangeText,
String? fieldStartHintText,
String? fieldEndHintText,
String? fieldStartLabelText,
String? fieldEndLabelText,
String? clearButtonString,
String? applyButtonString,
Locale? locale,
bool useRootNavigator = true,
RouteSettings? routeSettings,
TextDirection? textDirection,
TransitionBuilder? builder,
List<Widget>? actions,
bool isWeekMode = false,
int startingDayOfWeek = 0,
}) async =>
showZdsDateRangePicker(
firstDate: firstDate,
lastDate: lastDate,
context: context,
initialDateRange: initialDateRange,
currentDate: currentDate,
initialEntryMode: initialEntryMode,
helpText: helpText,
cancelText: cancelText,
confirmText: confirmText,
saveText: saveText,
errorFormatText: errorFormatText,
errorInvalidText: errorInvalidText,
errorInvalidRangeText: errorInvalidRangeText,
fieldStartHintText: fieldStartHintText,
fieldEndHintText: fieldEndHintText,
fieldStartLabelText: fieldStartLabelText,
fieldEndLabelText: fieldEndLabelText,
clearButtonString: clearButtonString,
applyButtonString: applyButtonString,
locale: locale,
useRootNavigator: useRootNavigator,
routeSettings: routeSettings,
textDirection: textDirection,
builder: builder,
actions: actions,
isWeekMode: isWeekMode,
startingDayOfWeek: startingDayOfWeek,
);

/// Shows a full screen modal dialog containing a Material Design date range
/// picker.
///
Expand Down
25 changes: 12 additions & 13 deletions lib/src/components/molecules/date_time_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:interval_time_picker/interval_time_picker.dart' as interval_picker;
import 'package:interval_time_picker/models/visible_step.dart';

import 'package:intl/intl.dart';
import 'package:zeta_flutter/zeta_flutter.dart';
Expand Down Expand Up @@ -87,6 +88,7 @@ class ZdsDateTimePicker extends StatefulWidget {
this.okClickText,
this.cancelClickText,
this.startDayOfWeek,
this.visibleStep = VisibleStep.fifths,
}) : format = (format?.isNotEmpty ?? false)
? format!
: (mode == DateTimePickerMode.date
Expand Down Expand Up @@ -177,6 +179,11 @@ class ZdsDateTimePicker extends StatefulWidget {
/// Starting day of week 1, 2, 3, Sunday, Monday, Tuesday respectively.
final int? startDayOfWeek;

/// Used when [interval] is set to determine the visible steps in the time picker.
///
/// Defaults to [VisibleStep.fifths].
final VisibleStep visibleStep;

@override
ZdsDateTimePickerState createState() => ZdsDateTimePickerState();

Expand Down Expand Up @@ -205,7 +212,8 @@ class ZdsDateTimePicker extends StatefulWidget {
..add(EnumProperty<TimePickerEntryMode>('timePickerEntryMode', timePickerEntryMode))
..add(StringProperty('okClickText', okClickText))
..add(StringProperty('cancelClickText', cancelClickText))
..add(IntProperty('startDayOfWeek', startDayOfWeek));
..add(IntProperty('startDayOfWeek', startDayOfWeek))
..add(EnumProperty<VisibleStep>('visibleStep', visibleStep));
}
}

Expand Down Expand Up @@ -371,20 +379,19 @@ class ZdsDateTimePickerState extends State<ZdsDateTimePicker> {
helpText: widget.helpText,
builder: timePickerBuilder,
)
: mounted
: context.mounted
? await interval_picker.showIntervalTimePicker(
context: context,
initialTime: initialValue,
interval: widget.interval!,
visibleStep: widget.visibleStep,
errorInvalidText: widget.timePickerErrorText,
initialEntryMode: _getIntervalPickerMode(),
builder: timePickerBuilder,
helpText: widget.helpText,
)
: null;

// final selectedTime = timePickerResult ?? (currentValue != null ? TimeOfDay.fromDateTime(currentValue) : null);

return timePickerResult;
}

Expand All @@ -410,13 +417,5 @@ class ZdsDateTimePickerState extends State<ZdsDateTimePicker> {
time?.minute ?? 0,
);

DateTime? _convert(TimeOfDay? time) => time == null
? null
: DateTime(
1,
1,
1,
time.hour,
time.minute,
);
DateTime? _convert(TimeOfDay? time) => time == null ? null : DateTime(1, 1, 1, time.hour, time.minute);
}
12 changes: 7 additions & 5 deletions lib/src/components/molecules/star_rating.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class ZdsStarRating extends StatefulWidget {

@override
State<ZdsStarRating> createState() => _ZdsStarRatingState();

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
Expand Down Expand Up @@ -109,6 +110,7 @@ class _ZdsStarRatingState extends State<ZdsStarRating> {
width: _boxSize * widget.size.toDouble(),
child: LayoutBuilder(
builder: (_, constraints) {
final borderRadius = widget.rounded ? Zeta.of(context).radius.rounded : Zeta.of(context).radius.none;
return GestureDetector(
onHorizontalDragStart: (details) => setState(() => _selected = true),
onHorizontalDragEnd: (details) => setState(() => _selected = false),
Expand All @@ -117,7 +119,7 @@ class _ZdsStarRatingState extends State<ZdsStarRating> {
duration: const Duration(milliseconds: 250),
decoration: BoxDecoration(
color: colors.cool.shade30.withOpacity(_selected ? 1 : 0),
borderRadius: widget.rounded ? BorderRadius.circular(8) : BorderRadius.circular(0),
borderRadius: borderRadius,
),
child: Row(
mainAxisSize: MainAxisSize.min,
Expand All @@ -126,7 +128,7 @@ class _ZdsStarRatingState extends State<ZdsStarRating> {
(int index) => SizedBox.square(
dimension: _boxSize,
child: InkWell(
borderRadius: widget.rounded ? BorderRadius.circular(8) : BorderRadius.circular(0),
borderRadius: borderRadius,
splashColor: colors.cool.shade30,
onTap: () {
if (widget.halfIncrements && index + 0.5 == _valueTapped) {
Expand Down Expand Up @@ -162,11 +164,11 @@ extension on _StarValue {
IconData icon({required bool rounded}) {
switch (this) {
case _StarValue.empty:
return rounded ? Icons.star_outline_rounded : Icons.star_outline_sharp;
return rounded ? ZetaIcons.star_outline_round : ZetaIcons.star_outline_sharp;
case _StarValue.half:
return rounded ? Icons.star_half_rounded : Icons.star_half_sharp;
return rounded ? ZetaIcons.star_half_round : ZetaIcons.star_half_sharp;
case _StarValue.full:
return rounded ? Icons.star_rounded : Icons.star_sharp;
return rounded ? ZetaIcons.star_round : ZetaIcons.star_sharp;
}
}
}
6 changes: 3 additions & 3 deletions lib/src/components/molecules/toast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ class ZdsToast extends StatelessWidget implements PreferredSizeWidget {
Color _backgroundColor(ZetaColors colors, ZdsToastColors toastColor) {
switch (toastColor) {
case ZdsToastColors.success:
return colors.surfacePositive.shade10;
return colors.surfacePositiveSubtle;
case ZdsToastColors.warning:
return colors.surfaceWarning.shade10;
return colors.surfaceWarningSubtle;
case ZdsToastColors.info:
return colors.surfaceInfo.shade10;
return colors.surfaceInfoSubtle;
case ZdsToastColors.error:
return colors.error.shade10;
case ZdsToastColors.primary:
Expand Down
6 changes: 6 additions & 0 deletions lib/src/components/organisms/calendar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class ZdsCalendar extends StatefulWidget {
this.previousTooltip,
this.nextTooltip,
this.selectedRange,
@Deprecated('This parameter is no longer used and will be removed in the next major version.')
bool showSelectedDateHeader = false,
}) : _variant = _ZdsCalendarVariant.switchable,
hasHeader = true;

Expand Down Expand Up @@ -101,6 +103,8 @@ class ZdsCalendar extends StatefulWidget {
this.previousTooltip,
this.nextTooltip,
this.selectedRange,
@Deprecated('This parameter is no longer used and will be removed in the next major version.')
bool showSelectedDateHeader = false,
}) : _variant = _ZdsCalendarVariant.monthly;

/// Shows a calendar in a fixed weekly format.
Expand Down Expand Up @@ -135,6 +139,8 @@ class ZdsCalendar extends StatefulWidget {
this.previousTooltip,
this.nextTooltip,
this.selectedRange,
@Deprecated('This parameter is no longer used and will be removed in the next major version.')
bool showSelectedDateHeader = false,
}) : _variant = _ZdsCalendarVariant.weekly,
hasHeader = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class ZdsChatAttachmentWidget extends StatelessWidget {

@override
Widget build(BuildContext context) {
final colors = Zeta.of(context).colors;
final zeta = Zeta.of(context);
final colors = zeta.colors;
final foregroundColor = iconColor(_fileType, context: context);
final layoutBuilder = LayoutBuilder(
builder: (context, constraints) {
Expand All @@ -48,7 +49,7 @@ class ZdsChatAttachmentWidget extends StatelessWidget {
margin: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: colors.surfacePrimary,
borderRadius: const BorderRadius.all(Radius.circular(8)),
borderRadius: zeta.radius.rounded,
border: Border.all(color: colors.borderSubtle),
),
child: Column(
Expand Down
24 changes: 12 additions & 12 deletions lib/src/components/organisms/file_picker/file_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ extension _Methods on ZdsFilePickerState {

final List<ZdsFileWrapper> list = [];

if (mounted) {
if (context.mounted) {
for (final GiphyGif gif in result) {
final itemsLength = controller.items.where((ZdsFileWrapper element) => !element.isLink).toList().length +
controller.remoteItems.length;
Expand All @@ -646,21 +646,21 @@ extension _Methods on ZdsFilePickerState {

if (list.isNotEmpty) widget.onPicked?.call(list);
} on Exception catch (e) {
if (mounted) widget.onError?.call(context, config, e);
if (context.mounted) widget.onError?.call(context, config, e);
} finally {
_busy = false;
}
}

Future<void> _handleCameraAction(BuildContext context) async {
try {
if (!mounted) return;
if (!context.mounted) return;
final photo = await ZdsCamera.takePhoto(
context,
showPreview: config.showCapturePreview,
useSystemCamera: config.useSystemCamera,
);
if (photo != null && mounted) {
if (photo != null && context.mounted) {
final file = await onPicked(
context,
ZdsFileWrapper(ZdsFilePickerOptions.CAMERA, photo),
Expand All @@ -670,23 +670,23 @@ extension _Methods on ZdsFilePickerState {
if (file != null) widget.onPicked?.call([file]);
}
} on Exception catch (e) {
if (mounted) widget.onError?.call(context, config, e);
if (context.mounted) widget.onError?.call(context, config, e);
} finally {
_busy = false;
}
}

Future<void> _handleVideoAction(BuildContext context) async {
try {
if (!mounted) return;
if (!context.mounted) return;
final maxVideoTimeInSeconds = config.maxVideoTimeInSeconds;
final video = await ZdsCamera.recordVideo(
context,
showCapturePreview: config.showCapturePreview,
maxVideoDuration: maxVideoTimeInSeconds != null ? Duration(seconds: maxVideoTimeInSeconds) : null,
);

if (video != null && mounted) {
if (video != null && context.mounted) {
final file = await onPicked(
context,
ZdsFileWrapper(ZdsFilePickerOptions.VIDEO, video),
Expand All @@ -696,7 +696,7 @@ extension _Methods on ZdsFilePickerState {
if (file != null) widget.onPicked?.call([file]);
}
} on Exception catch (e) {
if (mounted) widget.onError?.call(context, config, e);
if (context.mounted) widget.onError?.call(context, config, e);
} finally {
_busy = false;
}
Expand Down Expand Up @@ -758,7 +758,7 @@ extension _Methods on ZdsFilePickerState {
allowMultiple: allowMultiple,
);

if (result != null && mounted) {
if (result != null && context.mounted) {
final List<ZdsFileWrapper> processedFiles = <ZdsFileWrapper>[];
for (final PlatformFile file in result.files) {
final itemsLength = controller.items.where((ZdsFileWrapper element) => !element.isLink).toList().length +
Expand Down Expand Up @@ -789,7 +789,7 @@ extension _Methods on ZdsFilePickerState {
}
}
} on Exception catch (e) {
if (mounted) widget.onError?.call(context, config, e);
if (context.mounted) widget.onError?.call(context, config, e);
} finally {
_busy = false;
}
Expand Down Expand Up @@ -832,7 +832,7 @@ extension _Methods on ZdsFilePickerState {
}

if (exception != null) {
if (mounted) widget.onError?.call(context, config, exception);
if (context.mounted) widget.onError?.call(context, config, exception);
} else {
if (input.content != null) {
controller.addFiles(<ZdsFileWrapper>[input]);
Expand All @@ -842,7 +842,7 @@ extension _Methods on ZdsFilePickerState {

return null;
} on Exception catch (e) {
if (mounted) widget.onError?.call(context, config, e);
if (context.mounted) widget.onError?.call(context, config, e);
return null;
} finally {
_busy = false;
Expand Down
4 changes: 3 additions & 1 deletion lib/src/components/organisms/quill_editor/color_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ class ZdsQuillToolbarColorButton extends StatefulWidget {
}
}

// ignore: public_member_api_docs
/// Options for the color button.
/// See [QuillToolbarColorButtonOptions].
/// See [QuillToolbarBaseButtonOptions].
class ZdsQuillToolbarColorButtonState extends State<ZdsQuillToolbarColorButton> {
late bool _isToggledColor;
late bool _isToggledBackground;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/utils/tools/nested_flow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ZdsNestedFlow extends StatefulWidget {
);

/// Root page for the navigator.
@Deprecated('message')
@Deprecated('Use child or builder property instead')
final Page<dynamic>? rootPage;

/// Should page be closed when just root page remains on the stack, useful when added as root widget in TabBar.
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: zds_flutter
description: Zebra Design System components for Flutter. A selection of UI components from Zebra Technologies.
version: 2.0.0
version: 1.3.1
homepage: https://github.com/zebradevs/zds_flutter
repository: https://github.com/zebradevs/zds_flutter
issue_tracker: https://github.com/zebradevs/zds_flutter/issues
Expand Down

0 comments on commit 9f5e072

Please sign in to comment.