Unverified Commit 3ed0bbed authored by Taha Tesser's avatar Taha Tesser Committed by GitHub

`CupertinoActivityIndicator`: Add an interactive example (#103040)

parent 86e55df7
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for CupertinoActivityIndicator
import 'package:flutter/cupertino.dart';
void main() => runApp(const CupertinoIndicatorApp());
class CupertinoIndicatorApp extends StatelessWidget {
const CupertinoIndicatorApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const CupertinoApp(
theme: CupertinoThemeData(brightness: Brightness.light),
home: CupertinoIndicatorExample(),
);
}
}
class CupertinoIndicatorExample extends StatelessWidget {
const CupertinoIndicatorExample({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const <Widget>[
// Cupertino activity indicator with default properties.
CupertinoActivityIndicator(),
SizedBox(height: 10),
Text('Default'),
],
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const <Widget>[
// Cupertino activity indicator with custom radius and color.
CupertinoActivityIndicator(radius: 20.0, color: CupertinoColors.activeBlue),
SizedBox(height: 10),
Text(
'radius: 20.0\ncolor: CupertinoColors.activeBlue',
textAlign: TextAlign.center,
),
],
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const <Widget>[
// Cupertino activity indicator with custom radius and disabled animation.
CupertinoActivityIndicator(radius: 20.0, animating: false),
SizedBox(height: 10),
Text(
'radius: 20.0\nanimating: false',
textAlign: TextAlign.center,
),
],
),
],
),
)
);
}
}
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/cupertino.dart';
import 'package:flutter_api_samples/cupertino/activity_indicator/cupertino_activity_indicator.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Default and customized cupertino activity indicators', (WidgetTester tester) async {
await tester.pumpWidget(
const example.CupertinoIndicatorApp(),
);
// Cupertino activity indicator with default properties.
final Finder firstIndicator = find.byType(CupertinoActivityIndicator).at(0);
expect(tester.widget<CupertinoActivityIndicator>(firstIndicator).animating, true);
expect(tester.widget<CupertinoActivityIndicator>(firstIndicator).radius, 10.0);
// Cupertino activity indicator with custom radius and color.
final Finder secondIndicator = find.byType(CupertinoActivityIndicator).at(1);
expect(tester.widget<CupertinoActivityIndicator>(secondIndicator).animating, true);
expect(tester.widget<CupertinoActivityIndicator>(secondIndicator).radius, 20.0);
expect(tester.widget<CupertinoActivityIndicator>(secondIndicator).color, CupertinoColors.activeBlue);
// Cupertino activity indicator with custom radius and disabled animation.
final Finder thirdIndicator = find.byType(CupertinoActivityIndicator).at(2);
expect(tester.widget<CupertinoActivityIndicator>(thirdIndicator).animating, false);
expect(tester.widget<CupertinoActivityIndicator>(thirdIndicator).radius, 20.0);
});
}
...@@ -20,6 +20,12 @@ const Color _kActiveTickColor = CupertinoDynamicColor.withBrightness( ...@@ -20,6 +20,12 @@ const Color _kActiveTickColor = CupertinoDynamicColor.withBrightness(
/// ///
/// {@youtube 560 315 https://www.youtube.com/watch?v=AENVH-ZqKDQ} /// {@youtube 560 315 https://www.youtube.com/watch?v=AENVH-ZqKDQ}
/// ///
/// {@tool dartpad}
/// This example shows how [CupertinoActivityIndicator] can be customized.
///
/// ** See code in examples/api/lib/cupertino/activity_indicator/cupertino_activity_indicator.0.dart **
/// {@end-tool}
///
/// See also: /// See also:
/// ///
/// * <https://developer.apple.com/ios/human-interface-guidelines/controls/progress-indicators/#activity-indicators> /// * <https://developer.apple.com/ios/human-interface-guidelines/controls/progress-indicators/#activity-indicators>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment