基础组件库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

139 lines
3.7 KiB

  1. import 'dart:ui';
  2. import 'package:flutter/material.dart';
  3. class ShareAlert extends StatelessWidget {
  4. final Widget child;
  5. const ShareAlert({Key key, this.child}) : super(key: key); // 中间视图
  6. @override
  7. Widget build(BuildContext context) {
  8. return GestureDetector(
  9. child: Scaffold(
  10. backgroundColor: Colors.transparent,
  11. body: BackdropFilter(
  12. filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5), //背景
  13. child: Container(
  14. child: Column(
  15. children: <Widget>[
  16. Expanded(
  17. child: Center(child: child ?? Container()),
  18. ),
  19. _ShareAlertContent(),
  20. ],
  21. ),
  22. ), // 模糊化
  23. ),
  24. ),
  25. onTap: () {
  26. Navigator.of(context).pop();
  27. },
  28. );
  29. }
  30. }
  31. class _ShareAlertContent extends StatelessWidget {
  32. @override
  33. Widget build(BuildContext context) {
  34. return GestureDetector(
  35. onTap: () {},
  36. child: Container(
  37. width: double.infinity,
  38. decoration: BoxDecoration(
  39. color: Colors.white,
  40. borderRadius: BorderRadius.only(
  41. topLeft: Radius.circular(12),
  42. topRight: Radius.circular(12),
  43. ),
  44. ),
  45. child: SafeArea(
  46. top: false,
  47. child: Column(
  48. children: <Widget>[
  49. Container(
  50. margin: EdgeInsets.only(top: 8, bottom: 8),
  51. width: 62,
  52. height: 4,
  53. decoration: BoxDecoration(
  54. color: Color(0xffd8d8d8),
  55. borderRadius: BorderRadius.circular(2)),
  56. ),
  57. Text(
  58. '分享至',
  59. style: TextStyle(
  60. fontSize: 15,
  61. color: Color(0xff333333),
  62. fontWeight: FontWeight.bold),
  63. ),
  64. Container(
  65. margin:
  66. EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10),
  67. child: _createIcons(),
  68. ),
  69. GestureDetector(
  70. child: Container(
  71. margin: EdgeInsets.only(left: 12, right: 12, bottom: 10),
  72. padding: EdgeInsets.all(12),
  73. decoration: BoxDecoration(
  74. color: Color(0xfff3f3f3),
  75. borderRadius: BorderRadius.circular(8)),
  76. child: Center(
  77. child: Text(
  78. '取消',
  79. style: TextStyle(
  80. fontSize: 12,
  81. fontWeight: FontWeight.bold,
  82. color: Color(0xff999999)),
  83. ),
  84. ),
  85. ),
  86. onTap: () {
  87. Navigator.of(context).pop();
  88. },
  89. )
  90. ],
  91. ),
  92. ),
  93. ),
  94. );
  95. }
  96. Widget _createIcons() {
  97. return Wrap(
  98. spacing: 10,
  99. runSpacing: 10,
  100. children: List.generate(6, (index) {
  101. return _createIcon();
  102. }),
  103. );
  104. }
  105. Widget _createIcon() {
  106. return Container(
  107. width: 60,
  108. child: Column(
  109. children: <Widget>[
  110. Container(
  111. width: 40,
  112. height: 40,
  113. decoration: BoxDecoration(
  114. borderRadius: BorderRadius.circular(20),
  115. color: Colors.redAccent),
  116. ),
  117. Padding(
  118. padding: const EdgeInsets.only(top: 2, bottom: 2),
  119. child: Text(
  120. '分享平台',
  121. style: TextStyle(
  122. fontSize: 12,
  123. color: Color(0xff333333),
  124. fontWeight: FontWeight.bold),
  125. ),
  126. ),
  127. ],
  128. ),
  129. );
  130. }
  131. }