ANTIPALSU Label template editor using flutter

main.dart 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // Copyright (c) 2021 Razeware LLC
  2. //
  3. // Permission is hereby granted, free of charge, to any person obtaining a copy
  4. // of this software and associated documentation files (the "Software"), to deal
  5. // in the Software without restriction, including without limitation the rights
  6. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. // copies of the Software, and to permit persons to whom the Software is
  8. // furnished to do so, subject to the following conditions:
  9. //
  10. // The above copyright notice and this permission notice shall be included in
  11. // all copies or substantial portions of the Software.
  12. //
  13. // Notwithstanding the foregoing, you may not use, copy, modify, merge, publish,
  14. // distribute, sublicense, create a derivative work, and/or sell copies of the
  15. // Software in any work that is designed, intended, or marketed for pedagogical
  16. // or instructional purposes related to programming, coding, application
  17. // development, or information technology. Permission for such use, copying,
  18. // modification, merger, publication, distribution, sublicensing, creation of
  19. // derivative works, or sale is expressly withheld.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  23. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  27. // THE SOFTWARE.
  28. import 'arc_curves_painter.dart';
  29. import 'common/common_scaffold.dart';
  30. import 'grid/grid_widget.dart';
  31. import 'ovals_painter.dart';
  32. import 'polygon_painter.dart';
  33. import 'battery/animated_battery.dart';
  34. import 'package:flutter/material.dart';
  35. import 'package:flutter/services.dart';
  36. void main() {
  37. runApp(const MyApp());
  38. }
  39. class MyApp extends StatelessWidget {
  40. const MyApp({Key? key}) : super(key: key);
  41. @override
  42. Widget build(BuildContext context) {
  43. SystemChrome.setPreferredOrientations([
  44. DeviceOrientation.portraitUp,
  45. DeviceOrientation.portraitDown,
  46. ]);
  47. return MaterialApp(
  48. title: 'Canvas Basics',
  49. debugShowCheckedModeBanner: false,
  50. theme: ThemeData(
  51. primarySwatch: Colors.blue,
  52. ),
  53. home: HomeWidget(),
  54. );
  55. }
  56. }
  57. class HomeWidget extends StatelessWidget {
  58. HomeWidget({Key? key}) : super(key: key);
  59. final items = <Item>[
  60. Item('Polygons', GridWidget(PolygonPainter())),
  61. Item('Ovals and Circles', GridWidget(OvalPainter())),
  62. Item('Arc and Curves', GridWidget(ArcsCurvesPainter())),
  63. Item('Animated Battery', const AnimatedBattery()),
  64. ];
  65. @override
  66. Widget build(BuildContext context) {
  67. return CommonScaffold(
  68. title: 'Canvas Basics',
  69. child: Column(
  70. mainAxisSize: MainAxisSize.max,
  71. mainAxisAlignment: MainAxisAlignment.center,
  72. crossAxisAlignment: CrossAxisAlignment.center,
  73. children: items.map((e) => ItemWidget(e)).toList(),
  74. ),
  75. );
  76. }
  77. }
  78. // TODO: Rename project
  79. class ItemWidget extends StatelessWidget {
  80. final Item item;
  81. const ItemWidget(this.item, {Key? key}) : super(key: key);
  82. @override
  83. Widget build(BuildContext context) {
  84. return Container(
  85. width: double.infinity,
  86. margin: const EdgeInsets.symmetric(horizontal: 20, vertical: 7),
  87. child: TextButton(
  88. style: TextButton.styleFrom(
  89. foregroundColor: Colors.white, backgroundColor: const Color(0xFF158443),
  90. padding: const EdgeInsets.symmetric(vertical: 15)),
  91. onPressed: () {
  92. final widget = CommonScaffold(title: item.title, child: item.widget);
  93. Navigator.of(context)
  94. .push(MaterialPageRoute<void>(builder: (_) => widget));
  95. },
  96. child: Text(
  97. item.title,
  98. style: const TextStyle(
  99. fontSize: 18,
  100. fontWeight: FontWeight.bold,
  101. ),
  102. ),
  103. ),
  104. );
  105. }
  106. }
  107. class Item {
  108. final String title;
  109. final Widget widget;
  110. Item(this.title, this.widget);
  111. }