Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MOO:1611] support device font size accessibility for progress circle widget #188

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

### Added

- Support device font size for responsive progress circle sizing.

## [3.1.1] - 2023-3-28

### Changed

- Bumped react-native-progress dependency
- Bumped react-native-progress dependency.

## [3.1.0] - 2022-01-24

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "progress-circle-native",
"widgetName": "ProgressCircle",
"version": "3.1.1",
"version": "3.1.2",
"license": "Apache-2.0",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { available, flattenStyles, unavailable } from "@mendix/piw-native-utils-internal";
import { Component, createElement } from "react";
import { Text, View } from "react-native";
import { Text, View, PixelRatio } from "react-native";
import { Circle } from "react-native-progress";

import { ProgressCircleProps } from "../typings/ProgressCircleProps";
Expand All @@ -15,15 +15,15 @@ export class ProgressCircle extends Component<Props> {
const validationMessages = this.validate();
const progress = validationMessages.length === 0 ? this.calculateProgress() : 0;
const showsText = this.props.circleText !== "none";

return (
<View style={this.styles.container}>
<Circle
testID={this.props.name}
progress={progress}
textStyle={this.styles.text}
color={this.styles.fill.backgroundColor}
size={Number(this.styles.circle.size)}
// Update the progress size based on the device's font scale
size={Number(this.styles.circle.size) * PixelRatio.getFontScale()}
borderWidth={this.styles.circle.borderWidth}
borderColor={this.styles.circle.borderColor}
thickness={this.styles.fill.width}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { dynamicValue } from "@mendix/piw-utils-internal";
import { Big } from "big.js";
import { createElement } from "react";
import { Text } from "react-native";
import { Text, PixelRatio } from "react-native";
import { Circle } from "react-native-progress";
import { render } from "@testing-library/react-native";

import { ProgressCircle, Props } from "../ProgressCircle";

describe("ProgressCircle", () => {
it("renders", () => {
jest.spyOn(PixelRatio, "getFontScale").mockReturnValue(1);
const component = render(<ProgressCircle {...createProps(50, 0, 100)} />);
expect(component.toJSON()).toMatchSnapshot();
expect(component.UNSAFE_getByType(Circle).props.progress).toBe(0.5);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<package xmlns="http://www.mendix.com/package/1.0/">
<clientModule name="ProgressCircle" version="3.1.1" xmlns="http://www.mendix.com/clientModule/1.0/">
<clientModule name="ProgressCircle" version="3.1.2" xmlns="http://www.mendix.com/clientModule/1.0/">
<widgetFiles>
<widgetFile path="ProgressCircle.xml" />
</widgetFiles>
Expand Down
Loading