mirror of
				https://github.com/AppFlowy-IO/AppFlowy.git
				synced 2025-11-04 12:03:28 +00:00 
			
		
		
		
	chore: remove duplicated svg function
This commit is contained in:
		
							parent
							
								
									fba69767a7
								
							
						
					
					
						commit
						d7783a6440
					
				@ -20,7 +20,7 @@ class NewAppButton extends StatelessWidget {
 | 
				
			|||||||
      hoverColor: Colors.transparent,
 | 
					      hoverColor: Colors.transparent,
 | 
				
			||||||
      fontColor: Theme.of(context).colorScheme.onSurfaceVariant,
 | 
					      fontColor: Theme.of(context).colorScheme.onSurfaceVariant,
 | 
				
			||||||
      onPressed: () async => await _showCreateAppDialog(context),
 | 
					      onPressed: () async => await _showCreateAppDialog(context),
 | 
				
			||||||
      heading: svgWithSize("home/new_app", const Size(16, 16)),
 | 
					      heading: svgWidget("home/new_app", size: const Size(16, 16)),
 | 
				
			||||||
      padding: EdgeInsets.symmetric(horizontal: Insets.l, vertical: 20),
 | 
					      padding: EdgeInsets.symmetric(horizontal: Insets.l, vertical: 20),
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -207,8 +207,8 @@ class MenuTopBar extends StatelessWidget {
 | 
				
			|||||||
      return Container();
 | 
					      return Container();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return (Theme.of(context).brightness == Brightness.dark
 | 
					    return (Theme.of(context).brightness == Brightness.dark
 | 
				
			||||||
        ? svgWithSize("flowy_logo_dark_mode", const Size(92, 17))
 | 
					        ? svgWidget("flowy_logo_dark_mode", size: const Size(92, 17))
 | 
				
			||||||
        : svgWithSize("flowy_logo_with_text", const Size(92, 17)));
 | 
					        : svgWidget("flowy_logo_with_text", size: const Size(92, 17)));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
 | 
				
			|||||||
@ -118,7 +118,7 @@ class _CurrentIcon extends StatelessWidget {
 | 
				
			|||||||
                  margin: const EdgeInsets.all(5.0),
 | 
					                  margin: const EdgeInsets.all(5.0),
 | 
				
			||||||
                  decoration:
 | 
					                  decoration:
 | 
				
			||||||
                      BoxDecoration(border: Border.all(color: Colors.grey)),
 | 
					                      BoxDecoration(border: Border.all(color: Colors.grey)),
 | 
				
			||||||
                  child: svgWithSize('emoji/$iconUrl', const Size(60, 60)),
 | 
					                  child: svgWidget('emoji/$iconUrl', size: const Size(60, 60)),
 | 
				
			||||||
                )),
 | 
					                )),
 | 
				
			||||||
          ])),
 | 
					          ])),
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
				
			|||||||
@ -1,26 +1,13 @@
 | 
				
			|||||||
import 'package:flutter/widgets.dart';
 | 
					import 'package:flutter/widgets.dart';
 | 
				
			||||||
import 'package:flutter_svg/flutter_svg.dart';
 | 
					import 'package:flutter_svg/flutter_svg.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Widget svgWithSize(String name, Size size) {
 | 
					 | 
				
			||||||
  return SizedBox.fromSize(
 | 
					 | 
				
			||||||
    size: size,
 | 
					 | 
				
			||||||
    child: svgWidget(name),
 | 
					 | 
				
			||||||
  );
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Widget svgWidget(String name, {Size? size, Color? color}) {
 | 
					Widget svgWidget(String name, {Size? size, Color? color}) {
 | 
				
			||||||
  if (size != null) {
 | 
					  if (size != null) {
 | 
				
			||||||
    return SizedBox.fromSize(
 | 
					    return SizedBox.fromSize(
 | 
				
			||||||
      size: size,
 | 
					      size: size,
 | 
				
			||||||
      child: _svgWidget(name, color: color),
 | 
					      child: SvgPicture.asset('assets/images/$name.svg', color: color),
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    return _svgWidget(name, color: color);
 | 
					    return SvgPicture.asset('assets/images/$name.svg', color: color);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
Widget _svgWidget(String name, {Color? color}) {
 | 
					 | 
				
			||||||
  final Widget svg = SvgPicture.asset('assets/images/$name.svg', color: color);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  return svg;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user