Skip to content

Instantly share code, notes, and snippets.

View mazharulbelal's full-sized avatar
🇧🇩

Mazharul Belal mazharulbelal

🇧🇩
  • Dhaka
View GitHub Profile
@mazharulbelal
mazharulbelal / gist:379249586b7314a9f359eeb9ed005f48
Last active August 2, 2023 03:45
create account flutter page
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
void main() {
runApp(const MyApp());
}
//void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
void main() {
runApp(const MyApp());
}
//void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@mazharulbelal
mazharulbelal / Helper Method
Created June 23, 2022 10:53
Alamofire Cache policy setup
private func apiCalling(url: String,method: HTTPMethod,parameters: [String : Any]?,header: HTTPHeaders?, cachePolicy: Bool, completion: @escaping COMPLETION_HANDLER<Data>) {
let configuration = URLSessionConfiguration.default
configuration.requestCachePolicy = . reloadIgnoringLocalAndRemoteCacheData
var req = URLRequest(url: URL(string: url)!)
req.httpMethod = method.rawValue
req.headers = API_HEADER
req.cachePolicy = cachePolicy ? .returnCacheDataDontLoad : .reloadIgnoringLocalAndRemoteCacheData
AF.request(req)
.validate(statusCode: 200..<300)
@mazharulbelal
mazharulbelal / ViewController Present from SwiftUI Button Press
Last active June 13, 2022 11:29
Open UIKit ViewController( Present) on SwiftUI Button clicked
Button("Next Page") {
let storyboard = UIStoryboard(name: "Profile", bundle: nil)
let rootViewController = storyboard.instantiateViewController(withIdentifier: "ProfileVC")
if let window = UIApplication.shared.windows.first {
window.rootViewController!.present(rootViewController, animated: true)
}
}
}
@mazharulbelal
mazharulbelal / gist:7779f93237a39f02539b84a979c5347c
Last active June 13, 2022 05:33
Open SwiftUI ViewController from UIKit Button press
let controller = UIHostingController(rootView: SwiftUIView())
self.navigationController?.pushViewController(controller, animated: true)
extension Array {
func transtionDoctorTitle() -> String {
let titles = self.map {changeLanguage.key(key: doctorData[$0 as! String] ?? changeLanguage.key(key: notGivenKey))}
return titles.joined(separator: ", ")
}
}
// DOWNLOAD IMAGE FROM URL
extension UIImageView {
@mazharulbelal
mazharulbelal / gist:8d84a3713e4446a710dbfedbed3617cd
Created May 12, 2022 08:04
Load image from url with placeholder image SDWebImage extension swift
extension UIImageView {
func downloadImg(_ url: String) {
let afterRemovedSpaceImgPath = url.replacingOccurrences(of: " ", with: "%20", options: .literal, range: nil)
self.sd_imageIndicator = SDWebImageActivityIndicator.gray
self.sd_setImage(with: URL(string: afterRemovedSpaceImgPath), placeholderImage: UIImage(named: "PlaceHolder"))
}
}